HDU 5391-Zball in Tina Town(数论)】的更多相关文章

<题目链接> Zball in Tina Town Problem Description Tina Town is a friendly place. People there care about each other.Tina has a ball called zball. Zball is magic. It grows larger every day. On the first day, it becomes 1 time as large as its original siz…
Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Problem Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball is magic. It grows lar…
问题描述 Tina Town 是一个善良友好的地方,这里的每一个人都互相关心. Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大11倍.在第二天的时候,它会变大22倍.在第nn天的时候,它会变大nn倍. zball原来的体积是11.Tina想知道,zball在第n-1n−1天时的体积对nn取模是多大呢? Tina是一个蠢蠢的女孩子,当然不会算啦,所以她请你帮她算出这个答案呢. 输入描述 第一行一个正整数TT,表示数据组数 接下来TT行,每行一个正整…
题意: Tina有一个球,它的名字叫zball.zball很神奇,它会每天变大.在第一天的时候,它会变大1倍.在第二天的时候,它会变大2倍.在第n天的时候,它会变大n倍.zball原来的体积是1.Tina想知道,zball在第n−1天时的体积对n取模是多大呢? 思路: 如果n是一个合数,那它肯定是有因子的,即有两个比它小的数字a和b,使得a*b=n,那么答案必为0.如果是质数,打表可知是n-1.数字小的直接算,防止意外.数字都不会超过int. #include <cstdio> #includ…
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. HDUoj 5391 - Zball in Tina Town 在线提交: http://acm.hdu.edu.cn/showproblem.php?pid=5391 Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Ja…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5391 Problem Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball time times )-th day. Tina want to know its size on the (n-)-th day mo…
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5391 bc:  http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=616&pid=1001 Zball in Tina Town  Accepts: 356  Submissions: 2463  Time Limit: 3000/1500 MS (Java/Others)  Memory Limit:…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5391 相关数论结论: 威尔逊定理——当且仅当p为素数时:( p -1 )! ≡ p-1 ( mod p ) 这道题一开始看到的时候以为是暴力的题目,快速阶乘取模,后来其他题做不出来回头看这道题, 发现可以找规律,当p是合数的时候,P的因子全都可以在P前面的数字的因子里找到, 当p是素数的时候,(p-1)!%p = p-1,就尝试写了一下,2A: 因为4是个例外,怕还有其他例外情况,在100以内小规模…
题目地址:pid=5391">HDU 5391 题意: Tina Town 是一个善良友好的地方,这里的每个人都互相关心.Tina有一个球,它的名字叫zball. zball非常奇妙,它会每天变大. 在第一天的时候.它会变大11倍.在第二天的时候,它会变大22倍.在第nn天的时候,它会变大nn倍.zball原来的体积是11.Tina想知道,zball在第n-1n−1天时的体积对nn取模是多大呢?Tina是一个蠢蠢的女孩子.当然不会算啦,所以她请你帮她算出这个答案呢. 思路:这题就是求 n(…
题目传送门 /* 题意: 求(n-1)! mod n 数论:没啥意思,打个表能发现规律,但坑点是4时要特判! */ /************************************************ * Author :Running_Time * Created Time :2015-8-15 19:06:12 * File Name :A.cpp ************************************************/ #include <cstdi…
(n-1)!/n 就是如果n为素数,就等于n-1else为0. 求素数表: Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 833 Accepted Submission(s): 477 Problem Description Tina Town is a friendly place. People…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 219    Accepted Submission(s): 144 Problem Description Tina Town i…
Zball in Tina Town  Accepts: 541  Submissions: 2463  Time Limit: 3000/1500 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) 问题描写叙述 Tina Town 是一个善良友好的地方,这里的每个人都互相关心. Tina有一个球,它的名字叫zball.zball非常奇妙,它会每天变大.在第一天的时候,它会变大11倍. 在第二天的时候,它会变大22倍.在第…
Zball in Tina Town  Accepts: 356  Submissions: 2463  Time Limit: 3000/1500 MS (Java/Others)  Memory Limit: 262144/262144 K (Java/Others) Problem Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zba…
Problem Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball is magic. It grows larger every day. On the first day, it becomes 1 time as large as its original size. On the second day,it wi…
Problem Description There is a big stone with smooth surface in Tina Town. When people go towards it, the stone surface will be lighted and show its usage. This stone was a legacy and also the center of Tina Town’s calculation and control system. als…
[题目大意] 一个球初始体积为1,一天天变大,第一天变大1倍,第二天变大2倍,第n天变大n倍.问当第 n-1天的时候,体积变为多少.注意答案对n取模. [题解] 根据威尔逊定理:(n-1)! mod n =-1 所以当n为质数时,答案就是n-1 否则答案显然是0 注意4要特判一下,ans[4]=2 这里有一种很魔性的判素数的方法,详见代码 /************* HDU 5391 by chty 2016.11.4 *************/ #include<iostream> #i…
Infoplane in Tina Town Time Limit: 14000/7000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others) Total Submission(s): 805    Accepted Submission(s): 168 Problem Description There is a big stone with smooth surface in Tina Town. When peop…
题目链接 \(Description\) 给定一棵\(Trie\).求\(Trie\)上所有回文串 长度乘以出现次数 的和.这里的回文串只能是从上到下的一条链. 节点数\(n\leq 2\times 10^6\),字符集为a,b,c,d. \(Solution\) 如果不是树,就是回文树模板.对于树,DFS \(x\)的每个儿子的时候都用在\(x\)处的\(las\)即可,也就是按深度存一个\(las\)数组,每次用\(las[dep-1]\)做\(las\)去插入即可.(也可以回溯的时候直接删…
Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1401    Accepted Submission(s): 727 Problem Description Tina Town is a friendly place. People there care about each other. T…
E - 5 Time Limit:1500MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5391 Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball is magic. It grows…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Infoplane in Tina Town Time Limit: 14000/7000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 518    Accepted Submission(s): 74 Problem Description There i…
找新朋友 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7001    Accepted Submission(s): 3643 Problem Description 新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号,凡是和会长是老朋友的,那么该会员的号码肯定和N有大于1的公约数…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5392 #include<stdio.h> #include<cstring> #include<cmath> #include<algorithm> #include<set> using namespace std; *1e6+; ; int n, T; int a[MAXN]; int vis[MAXN]; int num[MAXN]; int…
Problem Description Let f(x) = anxn +...+ a1x +a0, in which ai (0 <= i <= n) are all known integers. We call f(x) 0 (mod m) congruence equation. If m is a composite, we can factor m into powers of primes and solve every such single equation after wh…
HDU 4983 Goffi and GCD 思路:数论题.假设k为2和n为1.那么仅仅可能1种.其它的k > 2就是0种,那么事实上仅仅要考虑k = 1的情况了.k = 1的时候,枚举n的因子,然后等于求该因子满足的个数,那么gcd(x, n) = 该因子的个数为phi(n / 该因子),然后再利用乘法原理计算就可以 代码: #include <cstdio> #include <cstring> #include <cmath> typedef long lo…
转载请注明出处:http://blog.csdn.net/u012860063? viewmode=contents 题目链接:pid=4279">http://acm.hdu.edu.cn/showproblem.php?pid=4279 HDU集训队选拔赛地点:3教3楼机房,时间:5月10日(周六)12:00開始.请相互转告,谢谢~ 百度之星编程大赛--您报名了吗?  Number Time Limit: 2000/1000 MS (Java/Others)    Memory Lim…
题意:给出 A%9973 和 B,求(A/B)%9973的值. 解法:拓展欧几里德求逆元.由于同余的性质只有在 * 和 + 的情况下一直成立,我们要把 /B 转化为 *B-1,也就是求逆元. 对于 B-1,P为模数9973,那么 B*B-1=1(mod P)  →  把 B-1 看成 x ,就是 Bx+Py=1.也就是求不定方程的解了.x 就是 B-1,答案就是 ((A%9973)*(x%9973))%9973 . P.S.关于拓展欧几里德求解不定方程的具体解释请见--[poj 2115]C L…
Remainder Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3036    Accepted Submission(s): 679 Problem Description Coco is a clever boy, who is good at mathematics. However, he is puzzled by a d…
CA Loves GCD 题目链接: http://acm.hust.edu.cn/vjudge/contest/123316#problem/B Description CA is a fine comrade who loves the party and people; inevitably she loves GCD (greatest common divisor) too. Now, there are different numbers. Each time, CA will se…