BestCoder Round #51 (div.2) A

Zball in Tina Town

Accepts: 397

Submissions: 2463

Time Limit: 3000/1500 MS (Java/Others)

Memory Limit: 262144/262144 K (Java/Others)

问题描述

Tina Town 是一个善良友好的地方,这里的每一个人都互相关心。
Tina有一个球,它的名字叫zball。zball很神奇,它会每天变大。在第一天的时候,它会变大111倍。在第二天的时候,它会变大222倍。在第nnn天的时候,它会变大nnn倍。
zball原来的体积是111。Tina想知道,zball在第n?1n-1n?1天时的体积对nnn取模是多大呢?
Tina是一个蠢蠢的女孩子,当然不会算啦,所以她请你帮她算出这个答案呢。

输入描述

第一行一个正整数TTT,表示数据组数
接下来TTT行,每行一个正整数nnn,意义如题面所述
T≤105,2≤n≤109T \leq 10^5,2 \leq n \leq 10^9T≤10?5??,2≤n≤10?9??

输出描述

对于每组数据,输出一个正整数,表示答案。

输入样例

2
3
10

输出样例

2

0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define LL long long
using namespace std;
LL n,m;
bool su(LL n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
        return false;
    }
    return true;
}
int main()
{
    LL y,x,k,t,s,l,r;
    LL cla;
    scanf("%lld",&cla);
    while(cla--)
    {
        scanf("%lld",&n);
        if(n==4)
        printf("2\n");
        else if(su(n))//威尔逊定理
        {
            printf("%lld\n",n-1);
        }
        else
           printf("0\n");
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-03 15:56:19

BestCoder Round #51 (div.2) A的相关文章

BestCoder Round #51 (div.2)

明显是无良心的数学round= = 1000 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 #define PAU putchar(' ') 9 #defin

BestCoder Round #51 (div.2) Zball in Tina Town

威尔逊定理:当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p )    这是一个充分必要条件 这道题是用威尔逊定理做,但不知道定理的话,也没关系,可以打个表, 总结:数论一些题就算不知道某个知识点,也要试着打下表,看能不能找到规律 #include<cstdio> int main() { for(int i=1;i<=13;i++) { int sum=1; for(int j=1;j<i;j++) sum*=j; printf("%d\n"

DP BestCoder Round #50 (div.2) 1003 The mook jong

题目传送门 1 /* 2 DP:这题赤裸裸的dp,dp[i][1/0]表示第i块板放木桩和不放木桩的方案数.状态转移方程: 3 dp[i][1] = dp[i-3][1] + dp[i-3][0] + 1; dp[i][0] = dp[i-1][1] + dp[i-1][0]; 4 比赛时二维dp写搓了,主要是边界情况的判断出错,比如dp[3][1] = 1,因为第3块放了木桩,其他地方不能再放,dp[3][0]同理 5 解释一下dp[i][1]的三种情况,可能是前面相隔2个放的方案或者是不放的

计算几何(水)BestCoder Round #50 (div.2) 1002 Run

题目传送门 1 /* 2 好吧,我不是地球人,这题只要判断正方形就行了,正三角形和正五边形和正六边形都不可能(点是整数). 3 但是,如果不是整数,那么该怎么做呢?是否就此开启计算几何专题了呢 4 */ 5 /************************************************ 6 * Author :Running_Time 7 * Created Time :2015-8-8 19:54:14 8 * File Name :B.cpp 9 ************

hdu5418 BestCoder Round #52 (div.2) Victor and World ( floyd+状压dp)

Problem Description After trying hard for many years, Victor has finally received a pilot license. To have a celebration, he intends to buy himself an airplane and fly around the world. There are n countries on the earth, which are numbered from 1 to

BestCoder Round #11 (Div. 2) 前三题题解

题目链接: huangjing hdu5054 Alice and Bob 思路: 就是(x,y)在两个參考系中的表示演全然一样.那么仅仅可能在这个矩形的中点.. 题目: Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 216    Accepted Submission(s): 166 Problem De

BestCoder Round #11 (Div. 2) 题解

HDOJ5054 Alice and Bob Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 302    Accepted Submission(s): 229 Problem Description Bob and Alice got separated in the Square, they agreed that if they

HDU 5651 xiaoxin juju needs help(BestCoder Round #77 (div.1)1001)

传送门 xiaoxin juju needs help Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 861    Accepted Submission(s): 243 Problem Description As we all known, xiaoxin is a brilliant coder. He knew **palin

BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 681    Accepted Submission(s): 280 Problem Description Baby Ming is fond of weight lifting. He has a barbell pole(the