标签:code int 数据 mes put class NPU des ace
3
2
3
4
1
2
3
若n为奇数,则a和b相差 1 最优 若n为偶数,令m = n/2,若m ? 1和m + 1均为奇数,则a = m ? 1, b = m + 1 否则a = m ? 2, b = m + 2
1 #include<cstdio> 2 using namespace std; 3 int n,m; 4 long long xx; 5 int main() 6 { 7 scanf("%d",&n); 8 for (int i=1;i<=n;i++) 9 { 10 scanf("%d",&m); 11 if (m==2) 12 { 13 printf("1\n"); 14 continue; 15 } 16 if (m%2!=0) 17 { 18 long long m1=m/2,m2=(m-m1); 19 xx=m1*m2; 20 printf("%lld\n",xx); 21 } 22 else 23 { 24 m=m/2; 25 if ((m+1)%2==0) 26 { 27 long long m1=m+2,m2=m-2; 28 xx=m1*m2; 29 printf("%lld\n",xx); 30 } 31 else 32 { 33 long long m1=m-1,m2=m+1; 34 xx=m1*m2; 35 printf("%lld\n",xx); 36 } 37 } 38 } 39 }
标签:code int 数据 mes put class NPU des ace
原文地址:https://www.cnblogs.com/Tokisaki-Kurumi/p/9532908.html