HDOJ 题目2973 YAPTCHA(数学,威尔逊定理)
来源:互联网 发布:怎么进淘宝卖家中心 编辑:程序博客网 时间:2024/05/17 23:04
YAPTCHA
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 584 Accepted Submission(s): 330
Problem Description
The math department has been having problems lately. Due to immense amount of unsolicited automated programs which were crawling across their pages, they decided to put Yet-Another-Public-Turing-Test-to-Tell-Computers-and-Humans-Apart on their webpages. In short, to get access to their scientific papers, one have to prove yourself eligible and worthy, i.e. solve a mathematic riddle.
However, the test turned out difficult for some math PhD students and even for some professors. Therefore, the math department wants to write a helper program which solves this task (it is not irrational, as they are going to make money on selling the program).
The task that is presented to anyone visiting the start page of the math department is as follows: given a natural n, compute
where [x] denotes the largest integer not greater than x.
However, the test turned out difficult for some math PhD students and even for some professors. Therefore, the math department wants to write a helper program which solves this task (it is not irrational, as they are going to make money on selling the program).
The task that is presented to anyone visiting the start page of the math department is as follows: given a natural n, compute
where [x] denotes the largest integer not greater than x.
Input
The first line contains the number of queries t (t <= 10^6). Each query consist of one natural number n (1 <= n <= 10^6).
Output
For each n given in the input output the value of Sn.
Sample Input
1312345678910100100010000
Sample Output
0112222334282071609
Source
Central European Programming Contest 2008
Recommend
lcy | We have carefully selected several similar problems for you: 2970 2966 2967 2968 2969
思路:
这里需要应用素数判断的Wilson定理:
ac代码
#include<stdio.h>#include<string.h>#include<math.h>int a[1000010];int pre(int n){int i;for(i=2;i<=sqrt(n);i++){if(n%i==0)return 0;}return 1;}void fun(){int i;a[0]=0;for(i=1;i<=1000010;i++)a[i]=a[i-1]+pre(i*3+7);}int main(){int t;fun();scanf("%d",&t);while(t--){int n;scanf("%d",&n);printf("%d\n",a[n]);}}
0 0
- HDOJ 题目2973 YAPTCHA(数学,威尔逊定理)
- 【威尔逊定理】HDOJ YAPTCHA 2973
- HDU 2973 YAPTCHA(威尔逊定理)
- HDU 2973 YAPTCHA(威尔逊定理)
- HDU 2973 YAPTCHA [威尔逊定理]
- HDU 2973 YAPTCHA 威尔逊定理
- YAPTCHA(数论“威尔逊定理”)
- hdu2973 YAPTCHA(威尔逊定理)
- hdu2973 YAPTCHA(威尔逊定理)
- HDU 2973 YAPTCHA(威尔逊定理+前缀和)
- (hdu 2973 YAPTCHA) <数论—威尔逊定理>
- Hdu 2973 YAPTCHA (数论 威尔逊定理)
- ACM 数论 HDU 2973 YAPTCHA 威尔逊定理
- UVA - 1434 YAPTCHA (威尔逊定理)
- Uva1434 YAPTCHA(威尔逊定理应用)
- HDOJ 2973 YAPTCHA
- HDOJ 题目4651Partition(数学,五边形数定理)
- UVA 1434 YAPTCHA(威尔逊定理简单应用)
- 数据结构:堆
- Adapter——notifyDataSetChanged
- uva 1546 - Complete the sequence!(牛顿插值法)
- 关于STM32中RTC的校准方法
- 【DataStrcutre】Introduction and description of Binary Trees
- HDOJ 题目2973 YAPTCHA(数学,威尔逊定理)
- HT图形组件设计之道(三)
- PAT 1043. Is It a Binary Search Tree (25)
- Cocos2d-x层(Layer)动画的实现
- 记一些琐碎的东西
- Scala学习笔记
- [Docker]初次接触
- uva 684 - Integral Determinant(行列式求值)
- debian系统时间设置