HDU 5922 Minimum’s Revenge
一道很水的题目
易知所有的点连到1点时最小
只是一定要注意输出格式
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; inline int read(){ int x=0,f=1,ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int main(){ int T=read(); for(int i=1;i<=T;i++){ int n=read(); unsigned long long ans; if(n&1) ans=1ll*(n+1)/2*n; else ans=1ll*n/2*(n+1); --ans; printf("Case #%d: %lld\n",i,ans); } return 0; }