Openjudge Exercise Solution (c + +)--Question 4,010:2011

Source: Internet
Author: User

Problem:

Total time limit:
1000ms
Memory Limit:
65536kB
Describe
A
positive integer n with a maximum length of 200 bits is known, and the latter four bits of the 2011^n are requested.
Input
The first behavior is a positive integer k, which represents the K-group data, k<=200 the next K-line,

Each row has a positive integer n,n number of digits <=200
Output
the result of each n is a single integer row, if less than 4 bits, the removal of high-level redundant 0
Sample input
3528792
Sample output
1051815521

Solution:

#include<iostream>#include<string>using namespaceStd;int Main(){intN;Cin>>N;string J; for(intI=0;I<N;I++){Cin>>J;intJj;//int jj= (j[j.length () -1]-48) *1+ (J[j.length () -2]-48) *10+ (J[j.length () -3]-48) *100;if (J.size() <3)J=" A"+J; {J=J.substr((int)J.size()-3,3);Jj=(J[0]- -)* -+(J[2]- -)+Ten*J[1]-480;}intR= .;if(Jj% -==0){cout<<1<<Endl;Continue;}intU=Jj% -; while(U>1){R*= .;R%=10000;U--;}cout<<R<<Endl;}return 0;}

Openjudge Exercise Solution (c + +)--Question 4,010:2011

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.