3.1w+
社区成员
#include <iostream>
#include <string>
using namespace std;
bool check(int n)
{
string str = to_string(n);
int len = str.length();
for(int i = 0; i < len; i ++)
{
if(str[i] == '2' || str[i] == '4')
return false;
}
return true;
}
int main()
{
int res = 0;
for(int i = 1; i <= 673; i ++)
{
for(int j = i + 1; j < 2019 - i - j; j ++)
{
int k = 2019 - i - j;
if(check(i) && check(j) && check(k))
res ++;
}
}
cout << res <<endl;
return 0;
}
#include <iostream>
using namespace std;
int main()
{
for(int y = 1900; y < 2012; y ++)
{
for(int d = 1; d <= 30; d ++)
{
int num = y * 10000 + 6 * 100 + d;
if(num % 2012 == 0 && num % 3 == 0 && num % 12 == 0)
{
cout << num << endl;
return 0;
}
}
}
}
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int a = 0, b = 0;
for(int i = 0; i < n; i ++)
{
int x = 0;
cin >> x;
if(x >= 85)
{
a ++;
b ++;
}
else if(x >= 60)
a ++;
}
cout << int((a * 1.0 / n) * 100 + 0.5) << "%" << endl;
cout << int((b * 1.0 / n) * 100 + 0.5) << "%" << endl;
return 0;
}
#include <iostream>
#include <cstring>
using namespace std;
const int N = 10010;
int a[N], f[N], inf=0x3f3f3f3f;
int n;
bool prime(int x)
{
for(int i = 2; i * i <= x; i ++)
{
if(x % i == 0)
return false;
}
return true;
}
int result(int y)
{
if(y == 1)
return 1;
for(int i = 2; i <= y; i ++)
{
if(y % i == 0 && prime(i))
return i;
}
}
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
memset(f, -inf, sizeof(f));
f[1] = a[1];
for(int i = 1; i <= n; i ++)
{
int r = result(n - i);
for(int j = i + 1; j <= i + r; j ++)
{
if(f[j] == -inf) f[j] = a[j] + f[i];
else f[j] = max(f[j], f[i] + a[j]);
}
}
cout << f[n] << endl;
return 0;
}