LightOJ 1370 Bi-shoe and Phi-shoe
来源:互联网 发布:unity3d 给模型加动画 编辑:程序博客网 时间:2024/05/12 20:25
Problem
lightoj.com/login_main.php?url=volume_showproblem.php?problem=1370
vjudge.net/contest/70017#problem/A
Reference
菜鸟系列——欧拉函数
数论学习笔记 欧拉函数 (一些性质和运用)内置杜教筛
LightOJ1370
Meaning
有 n 个数
Analysis
最终结论是:对于
对于这样的
Code
#include <cstdio>#include <algorithm>using namespace std;const int N = 10000, P = 1000007;int prime[P] = {0};int sieve(){ int n = 0; for(int i = 2; i < P; ++i) { if(!prime[i]) prime[n++] = i; // prime[j] <= P / i,等号不能去掉! for(int j = 0; j < n && prime[j] <= P / i; ++j) { prime[i * prime[j]] = 1; if(i % prime[j] == 0) break; } } return n;}int main(){ int np = sieve(), T; scanf("%d", &T); for(int Case = 1; Case <= T; ++Case) { int n; scanf("%d", &n); long long sum = 0; for(int ln, *p; n--; ) { scanf("%d", &ln); p = lower_bound(prime, prime + np, ln); if(*p == ln) ++p; sum += *p; } printf("Case %d: %lld Xukha\n", Case, sum); } return 0;}
阅读全文
0 0
- lightOj 1370 Bi-shoe and Phi-shoe
- LightOJ-1370 Bi-shoe and Phi-shoe
- LightOj 1370 Bi-shoe and Phi-shoe
- LightOJ 1370 Bi-shoe and Phi-shoe
- lightOj 1370 Bi-shoe and Phi-shoe
- LightOJ-1370 Bi-shoe and Phi-shoe
- LightOJ 1370 Bi-shoe and Phi-shoe
- Bi-shoe and Phi-shoe LightOJ
- Bi-shoe and Phi-shoe LightOJ
- Bi-shoe and Phi-shoe LightOJ
- Bi-shoe and Phi-shoe LightOJ
- LightOJ 1370 Bi-shoe and Phi-shoe (欧拉筛)
- LightOJ 1370 Bi-shoe and Phi-shoe(素数筛)
- LightOJ 1370 Bi-shoe and Phi-shoe 欧拉函数
- LightOJ 1370 Bi-shoe and Phi-shoe(素数)
- LightOJ 1370- Bi-shoe and Phi-shoe (欧拉函数)
- LightOj 1370 Pi shoe and Phi shoe
- Bi-shoe and Phi-shoe
- 欢迎使用CSDN-markdown编辑器
- cxf未开启服务端时产生的报错org.apache.cxf.interceptor.Fault: Could not send Message.
- PyQt5 实时获取屏幕界面图像,python3使用matplotlib
- 声明包名时package开头的p报错(字母p下面有红线)
- python3 学习之路1
- LightOJ 1370 Bi-shoe and Phi-shoe
- 图片的平移
- Spring自定义面向切面编程(AOP)
- Linux信号简述
- 类中引入的实体类报错(出现大量红线)
- 1. 策略模式
- 对象保护计数类
- deleted object would be re-saved by cascade (remove deleted object from asso错误
- Windows下python连接、操作oracle数据库(cx_Oracle)