HDU 4506 James series story-help me

Source: Internet
Author: User

Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 4506

Find the rule and determine the coefficient before the T power of K.

 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 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.