Title Address: HDU 5391
Test instructions
Tina town is a kind and friendly place where everyone cares about each other. Tina has a ball whose name is Zball. Zball is amazing, it gets bigger every day. On the first day, it will be 11 times times bigger. On the second day, it will be 22 times times bigger. On the first NN day, it will become larger than the NN. The original volume of Zball is 11. Tina would like to know how big the volume of Zball in the first n-1n?1 of the NN? Tina is a stupid girl, of course not, so she asked you to help her figure out the answer.
Idea: The problem is to ask N (n?1)! N If n is composite, the answer is obviously 0. If n is a prime number, then the answer is n-1 by Wilson's theorem. Pay attention to the case of n=4, the output is 2.
#include <stdio.h>#include <math.h>#include <string.h>#include <stdlib.h>#include <iostream>#include <sstream>#include <algorithm>#include <set>#include <queue>#include <stack>#include <map>#pragma COMMENT (linker, "/stack:102400000,102400000")using namespace STD;typedef__int64 LL;Const intinf=0x3f3f3f3f;Const DoublePi=ACOs(-1.0);Const Doubleesp=1e-7;intMain () {intT,n,i;scanf("%d", &t); while(t--) {scanf("%d", &n);if(n==4) {puts("2");Continue; }intflag=0;intm=sqrt(n1); for(i=2; i<=m; i++)if(n%i==0) {flag=1; Break; }if(!flag)printf("%d\n", N-1);Else printf("0\n"); }return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
HDU 5391-zball in Tina town (number theory)