摘要: //字符串输入流的使用#include#include#include //字符串输入流头文件using namespace std;char s[150];char ans[150];string w;int main(){ int t; while(scanf("%d", &t) != EOF){ getchar(); while(t--){ gets(s); for(int i=0; s[i]; i++){ if(s[i] >= 'a' && s[i] >w){ ans[j++] = w[0]; } ans[j] = 阅读全文
posted @ 2014-01-19 21:08 静坐观雨 阅读(189) 评论(0) 推荐(0)
摘要: #includeusing namespace std;const int maxn = 3000000 + 10;__int64 p[maxn];void init(){ for(int i=1; i>a>>b){ __int64 ans = 0; for(int i=a; i<=b; i++){ ans += p[i]; } cout<<ans<<endl; } return 0;} 阅读全文
posted @ 2014-01-19 20:18 静坐观雨 阅读(116) 评论(0) 推荐(0)
摘要: //欧拉函数模板#include#includeusing namespace std;int euler(int n){ //欧拉函数 int ans = n; int s = sqrt((double)n); for(int i=2;i 1) ans = ans / n * (n - 1); return ans;}int main(){ int n; while(scanf("%d", &n) !=EOF, n){ cout<<n - euler(n) - 1<<endl; //除了质数后就是和n的公约数大于等于2的数 } return 阅读全文
posted @ 2014-01-19 14:52 静坐观雨 阅读(122) 评论(0) 推荐(0)
摘要: /*欧拉函数ψ(N)=N{∏p|N}(1-1/p)亦即:ψ(N)=(P是数N的质因数)如:ψ(10)=10×(1-1/2)×(1-1/5)=4ψ(30)=30×(1-1/2)×(1-1/3)×(1-1/5)=8ψ(49)=49×(1-1/7)==42*/#include#includeusing namespace std;int euler(int n){ //欧拉函数 int ans = n; int s = sqrt((double)n); for(int i=2;i 1) ans = ans / n * (n - 1); re 阅读全文
posted @ 2014-01-19 14:15 静坐观雨 阅读(305) 评论(0) 推荐(0)