Remainder 2015 Guang Gong school game C Magic Quest

Source: Internet
Author: User

Topic Portal

Test instructions: Ask n-bits to divide the minimum number of 47

Analysis: Hit the table found in front are 100000 ..., the latter two is 100000%47 to 47 of the distance, is the fast power to find the value of 1000000%47, 47-It is the latter two

#include <bits/stdc++.h>using namespace Std;const int A = 47;int pow_mod (int x, int n, int p) {int ret = 1;while (n) { if (n & 1) ret = 1LL * RET * x% p;x = 1ll * x * x% p;n >>= 1;} return ret;} int run (int n) {return a-pow_mod (ten, N, A);} int main (void) {int t;scanf ("%d", &t), while (t--) {int n;scanf ("%d", &n), if (n <= 0) puts ("1"); else if (n = = 1  Puts ("0"), else if (n = = 2) puts ("+"), else{printf ("1"); for (int i=1; i<=n-3; ++i) printf ("0"); int x = run (n-1); (x < Ten) printf ("0%d\n", x); elseprintf ("%d\n", x);}} return 0;}

  

Remainder 2015 Guang Gong school game C Magic Quest

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.