赛后补题!!!
M-Monika's game
题意
将数字n进行拆分,求每次拆分之后乘积之和的最大值。
思路
每次都将数字x拆分为1和x-1,则1+2+3+......+n-1=n*(n-1)/2。
代码
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0), cout.tie(0);
using namespace std;
const int N=1e5+9;
int main()
{
int t;
scanf("%d",&t);
long long x;
for(int i=1;i<=t;i++) {
scanf("%lld",&x);
printf("%lld\n",x*(x-1)/2);
}
return 0;
}
F-不规则的轮回
题意
给定n个数对,每个数对中若 x > y , x = x -y ;若 x < y , y = y - x;求所询问的数对出现的次数。
思路
在进行操作的同时记录每对数对出现的次数。
代码