标签:奇数 style hit max 语言 typedef log stream 排列
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 #define maxn 100005 5 typedef long long ll; 6 ll a[maxn]; 7 int main() 8 { 9 ll n,l,r; 10 while(cin>>n>>l>>r) 11 { 12 for(int i=l;i<=r;i++) 13 a[i]=0; 14 15 for(int i=l;i<=r;i++) 16 { 17 for(int j=2;j<=n;j++) 18 { 19 if(i%j==0) 20 a[i]^=1; 21 } 22 } 23 int res=0; 24 for(int i=l;i<=r;i++) 25 { 26 if(a[i]) 27 res++; 28 } 29 cout<<res<<endl; 30 31 } 32 return 0; 33 }
1 #include <iostream> 2 #include <vector> 3 #include <string> 4 #include <algorithm> 5 6 int main() 7 { 8 using namespace std; 9 long long n, l, r; 10 while (cin >> n >> l >> r) { 11 int temp = sqrt((double)l); 12 long long i = temp * temp; 13 long long ans = -1; 14 if (i == l) { 15 ans++; 16 } 17 while (i <= r) { 18 ans++; 19 temp++; 20 i = temp * temp; 21 } 22 cout << r - l + 1 - ans << endl; 23 } 24 return 0; 25 }
标签:奇数 style hit max 语言 typedef log stream 排列
原文地址:http://www.cnblogs.com/qqky/p/6978141.html