A ABC400 Party(ABC400 党)
【题目链接】
原题链接:A - ABC400 Party
【考点】
判断
【题目大意】
400人排成一个矩形队形,输入多少人一排,求要多少列。
【解析】
如果能够整除400,这输出 400 / n,否则输出 -1。
【难度】
GESP二级
【代码参考】
#include<bits/stdc++.h>
using namespace std;int main(){int n;cin >> n;if(400 % n == 0)cout << 400 / n;else cout << -1;return 0;
}
B Sum of Geometric Series(几何级数之和)
【题目链接】
原题链接:B - Sum of Geometric Series
【考点】
枚举
【题目大意】
求 n 的 1~m 次方的和。
【解析】
主要是计算一个特定的数列求和,并判断求和结果是否会超出给定的范围(在代码中该范围上限定义为 N = 1e9)。若超出范围或者在计算过程中出现溢出(结果为负数),则输出" inf ";否则,输出计算得到的求和结果。将 ans 乘以 n,相当于计算 n 的幂次。
【难度】
GESP二级
【代码参考】
#include<bits/stdc++.h>
using namespace std;const int N = 1e9;int main(){int n, m, f = 0;int ans = 1, x = 1;cin >> n >