4088

daredsakura
LLMing
kuso

Dasseinzumtode

Frank_05
JingNian
aqbqlgh

AcCat
May_Emma
tideline

hri

2个月前
/*
【注意】
1.如果使用暴力穷举的方法则会超时，因为数据范围很大，所以需要进行优化
2.如果i是x的约数，则i/x也是x的约数。因此判断条件为i/x <= x,即i*i <= x,再对特殊情况进行处理
3.注意6*6=36这种情况，不能算成两个6
*/
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;
while(n --) {
int x;
cin >> x;
int s = 0;
for(int i = 1;i * i <= x;i ++) {
if(x % i == 0) {
if(i < x)
s += i;
if(i != x / i && x / i < x)
s += x / i;
}
}
if (x == s) printf("%d is perfect\n",x);
else printf("%d is not perfect\n",x);
}
return 0;
}

2个月前
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
int n,m;
while(cin >> n >> m,n > 0 && m > 0) {
if(n > m)   swap(n,m);
int sum = 0;
for(int i = n;i <= m;i ++) {
cout << i << ' ';
sum += i;
}
cout << "Sum=" << sum << endl;
}
return 0;
}

2个月前
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;
int a = 0,b = 1;
for(int i = 0;i < n;i ++) {
cout << a << ' ';
int c = a + b;
a = b;
b = c;
}
return 0;
}

2个月前
/*
【注意】
1.有可能第一个数大于第二个数，则需要交换
2.C/C++中，对于非0数，都会解析为逻辑真，对于0解析为逻辑假
3.别忽略负数，正奇数对2取余是1，而负奇数对2取余为-1
*/
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
int n;
cin >> n;
while(n --) {
int x,y;
cin >> x >> y;
if(x > y)   swap(x,y);
int s = 0;
for(int i = x + 1;i < y;i ++)
if(i % 2)
s += i;
cout << s << endl;
}
return 0;
}

2个月前
#include <iostream>
using namespace std;

int main()
{
int n,t,x = 0,y = 0;
cin >> n;
for(int i = 0;i < n;i ++) {
cin >> t;
if(t >= 10 && t <= 20)
x ++;
else
y ++;
}
cout << x << " in" << endl;
cout << y << " out" << endl;
return 0;
}

2个月前
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;

int c = 0, r = 0, f = 0;
for (int i = 0; i < n; i ++ )
{
int k;
char t;
scanf("%d %c", &k, &t);  // scanf在读入字符时，不会自动过滤空格、回车、tab
if (t == 'C') c += k;
else if (t == 'R') r += k;
else f += k;
}

int s = c + r + f;
printf("Total: %d animals\n", s);
printf("Total coneys: %d\n", c);
printf("Total rats: %d\n", r);
printf("Total frogs: %d\n", f);
printf("Percentage of coneys: %.2lf %%\n", (double)c / s * 100);
printf("Percentage of rats: %.2lf %%\n", (double)r / s * 100);
printf("Percentage of frogs: %.2lf %%\n", (double)f / s * 100);

return 0;
}

2个月前
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;
for(int i = 1;i <= 10;i ++) {
printf("%d x %d = %d\n",i,n,i * n);
}
return 0;
}

2个月前
#include <iostream>
using namespace std;

int main()
{
int x,k = 0;
cin >> x;
while(true) {
if(k >= 6)    break;
if(x % 2 != 0)  {
cout << x << endl;
k ++;
}
x ++;
}
return 0;
}

2个月前
#include <iostream>
using namespace std;

int main()
{
int n;
cin >> n;
for(int i = 2;i < 10000;i ++) {
if(i % n == 2)
cout << i << endl;
}
return 0;
}

2个月前
#include <iostream>
using namespace std;

int main()
{
int n,m;
cin >> n >> m;
for(int i = 0,k = 1;i < n;i ++) {
for(int j = 0;j < m - 1;j ++) {
cout << k << ' ';
k ++;
}
cout << "PUM" << endl;
k ++;
}
return 0;
}