题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5922
题意就是给一个图,判断两个点的GCD,求一个最小值
可以知道,与1相连的GCD是最小的,也就是其本身。
#pragma GCC optimize(2) #include<stdio.h> #include<algorithm> #include<string.h> #include<queue> using namespace std; const int maxn = 500; const int inf = 0x3f3f3f3f; typedef long long ll; ll n; ll sum; int t1 = 1; int main() { //freopen("C://input.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { sum = 0; scanf("%lld", &n); sum = (2 + n)*(n - 1) / 2; printf("Case #%d: %lld\n",t1++, sum); } return 0; }
注意n要开ll,不然在运算的时候会爆ll
hdu 5922 Minimum’s Revenge (签到题)
猜你喜欢
转载自blog.csdn.net/Evildoer_llc/article/details/82928534
今日推荐
周排行