• hdu


    小明系列故事——师兄帮帮忙

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
    Total Submission(s): 5596    Accepted Submission(s): 1528

    Problem Description
      小明自从告别了ACM/ICPC之后,就开始潜心研究数学问题了,一则可以为接下来的考研做准备,再者可以借此机会帮助一些同学,尤其是漂亮的师妹。这不,班里唯一的女生又拿一道数学题来请教小明,小明当然很高兴的就接受了。不过等他仔细读题以后,发现自己也不会做,这下小明囧了:如果回复说自己不懂,岂不是很没面子?
      所以,他现在私下求你帮忙解决这道题目,题目是这样的:
      给你n个数字,分别是a1,a2,a3,a4,a5……an,这些数字每过一个单位时间就会改变,假设上一个单位时间的数字为a1’,a2’,a3’……an’,那么这个单位时间的数字a[i] = a[i - 1]’ * K(i == 1的时候a[1] = a[n]’ * K),其中K为给定的系数。
      现在的问题就是求第t单位时间的时候这n个数字变成了什么了?由于数字可能会很大,所以只要你输出数字对10^9 + 7取余以后的结果。
     
    Input
      输入数据第一行是一个正整数T,表示有T组测试数据;
      每组数据有两行,第一行包含输入三个整数n, t, k,其中n代表数字个数,t代表第t个单位时间,k代表系数;第二行输入n个数字ai,代表每个数字开始的时候是多少。

      [Technical Specification]
      T <= 100
      1 <= n <= 10 ^ 4
      0 <= t <= 10 ^ 9  其中 t = 0 表示初始状态
      1 <= k <= 10 ^ 9
      1 <= ai<= 10 ^ 9
     
    Output
      对于每组数据请输出第t单位时间后这n个数字变成了什么,输出的时候每两个数字之间输出一个空格,行末不要输出多余的空格,具体见样例。
     
    Sample Input
    2 3 2 5 1 2 3 3 0 5 1 2 3
     
    Sample Output
    50 75 25 1 2 3
     
    Source
     

    这题主要是判断数据处理之后的新的位置

    #include <map>
    #include <set>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <queue>
    #include <iostream>
    #include <stack>
    #include <cmath>
    #include <string>
    #include <vector>
    #include <cstdlib>
    //#include <bits/stdc++.h>
    //#define LOACL
    #define space " "
    using namespace std;
    //typedef long long LL;
    typedef __int64 Int;
    typedef pair<int, int> paii;
    const int INF = 0x3f3f3f3f;
    const double ESP = 1e-5;
    const double PI = acos(-1.0);
    const int MOD = 1e9 + 7;
    const int MAXN = 1e5 + 10;
    Int que[MAXN];
    Int pow_mod(Int k, Int t)  {
        Int temp = 1;
        Int ret = k;
        while(t)  {
            if(t & 1) temp *= ret;
            temp %= MOD;
            t >>= 1;
            ret *= ret;
            ret %= MOD;
        }
        return temp;
    }
    int main() {
        int T;
        scanf("%d", &T);
        Int n,t,k,temp;
        while(T--) {
            scanf("%I64d%I64d%I64d",&n,&t,&k);
            for(int i = 0;i < n;++i) {
                scanf("%I64d",&que[i]);
            }
            temp = pow_mod(k,t);
            for(int i = 0;i < n;++i) {
                que[i] = (que[i] * temp) % MOD;
            }
            int f = 0;
            for(int i = (n - t % n) % n;f < n;f++)  {
                if (f) printf(" %I64d", que[i]);
                else printf("%I64d", que[i]);
                i = (i + 1) % n;
            }
            printf("
    ");
        }
        return 0;
    }
    
    
    


  • 相关阅读:
    DeepEarth更新到Silverlight 4了
    Silverlight & Blend动画设计系列八:拖放(DragDrop)操作与拖放行为(DragBehavior)
    VS2010之vb.net:细节决定成败
    iVIEW: An Intelligent Video over InternEt and Wireless Access System
    Tianya Doc
    治疗咳嗽
    一个 研究 可视化的个人博客
    Windows自启动方式完全总结
    JAVA连接DB2
    JSP 与 Discuz整合
  • 原文地址:https://www.cnblogs.com/cniwoq/p/6770764.html
Copyright © 2020-2023  润新知