Bestcoder Round #51 (Div.2)

Source: Internet
Author: User
Tags mul

is clearly a round= of the mathematics of conscience =

Zball in Tina town
1#include <iostream>2#include <cstdio>3#include <cmath>4#include <algorithm>5#include <stack>6#include <queue>7#include <cstring>8 #definePAU Putchar (")9 #defineENT Putchar (' \ n ')Ten #defineSafe 6 One using namespacestd; AtypedefLong LongLL; - Const intmaxn=100000+Ten; - ll GCD (ll A, ll b) { the     returnb = =0? A:GCD (b, a%b); - } - LL N, x, MX; - ll Mul (ll A, ll B, ll P) { +ll tmp = (A * b-(LL) ((Long Double) a/p * b + 1e-8) *p); -     returnTMP <0? TMP +p:tmp; + } A ll Pow (ll A, ll B, ll P) { atLL ans =1; A%=p; -      for(LL i = b; i; I >>=1, a =Mul (A, A, p)) -         if(I &1) ans =Mul (ans, A, p); -     returnans; - } - BOOLCheck (ll A, ll N, LL R, ll s) { inLL ans = Pow (A, R, N), p =ans; -      for(inti =1; I <= s; i + +){ toAns =Mul (ans, ans, n); +         if(ans = =1&& P! =1&& P! = N-1)return true; -p =ans; the     } *     if(ans! =1)return true; $     return false;Panax Notoginseng } - BOOLMR (LL N) { the     if(N <=1)return false; +     if(n = =2)return true; A     if(n%2==0)return false; theLL r = N-1, S =0; +      while(r%2==0) R/=2, S + +; -      for(inti =0; i < Safe; i + +) $         if(Check (rand ()% (N-1) +1, N, R, s))return false; $     return true; - } - inline LL Read () { theLL x=0;BOOLsig=1;CharCh=GetChar (); -      for(;! IsDigit (CH); Ch=getchar ())if(ch=='-') sig=0;Wuyi      for(; isdigit (ch); Ch=getchar ()) x=Ten*x+ch-'0'; the     returnsig?x:-x; - } WuInlinevoidwrite (LL x) { -     if(x==0) {Putchar ('0');return;}if(x<0) Putchar ('-'), x=-x; About     intlen=0;StaticLL buf[ -]; while(x) buf[len++]=x%Ten, x/=Ten; $      for(inti=len-1; i>=0; i--) Putchar (buf[i]+'0');return; - } - intT; - intMain () { At=read (); LL x; +      while(t--){ thex=read (); -         if(x==3) {Write (2); ENT;Continue;} $         if(x==4) {Write (2); ENT;Continue;} the         if(MR (x)) write (X-1), ENT; the         ElseWrite0), ENT; the     } the //For (LL x=1;x<=100;x++) { - //LL fac=1; in //for (int i=2;i<x;i++) fac=fac*i%x;write (x); Pau;write (FAC); ENT; the //    } the     return 0; About}

Then the problem was at least one point, unknown

1001 Infoplane in Tina town

Obviously non-writable = =div1 no one is over = =

Bestcoder Round #51 (Div.2)

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.