• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
若忆_star
博客园    首页    新随笔    联系   管理    订阅  订阅
hdu 4506 小明系列故事——师兄帮帮忙

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4506

题目大意;找规律,判断k的t次幂前面的系数。

 1 #include <iostream>
 2 #include <cstdio>
 3 using namespace std;
 4 
 5 __int64 fun(__int64 a,__int64 b)
 6 {
 7     __int64 s=1;
 8     while (b)
 9     {
10         if (b%2==1)
11             s=s*a%1000000007;
12         a=a*a%1000000007;
13         b>>=1;
14     }
15     return s%1000000007;
16 }
17 
18 int main ()
19 {
20     int T;
21     __int64 a[10100];
22     scanf("%d",&T);
23     while (T--)
24     {
25         __int64 n,t,k;
26         scanf("%I64d%I64d%I64d",&n,&t,&k);
27         k=fun(k,t);
28         for (int i=0; i<n; i++)
29         {
30             scanf("%I64d",&a[i]);
31             a[i]=a[i]*k%1000000007;
32         }
33         t%=n;
34         printf("%I64d",a[(n+0-t)%n]);
35         for(int i=1; i<n; i++)
36             printf(" %I64d",a[(n+i-t)%n]);
37         printf ("\n");
38     }
39     return 0;
40 }

 

posted on 2014-08-06 14:16  若忆_star  阅读(193)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3