蓝桥杯 1443: [蓝桥杯][历届试题]数字游戏
基本思想:
卡了很久,主要是仍然不知道百分之十四的用例错在什么地方,后续在更新;
关键点:
1.不能用穷举模拟,时间复杂度受不了;
2.注意等差数列求解中避免整形浮点损失的问题;
3.注意int 和long long的范围,这题是典型的精度问题;
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<cstring>
using namespace std;
using std::vector;
int main()
{
long long n, k, t;
scanf("%lld %lld %lld", &n, &k, &t);
/*
num.resize(n);
int cnt = 0;
int time = 0;
int index = 0;
int st = 1;
int round = 1;
while (time<t){
index = index % n;
st = st % k;
num[index] = st;
//cout << st << endl;
st = st + round;
round++;
if (index == 0) {
cnt += num[index];
//cout << num[index]<<endl;
time++;
}
index++;
}
*/
long long cnt = 1;
for (long long i = 1; i <= t - 1; i++) {
long long time = n * i;
long long s = 1+(time+1)*time/2;
cout << s << endl;
s = s % k;
cnt += s;
}
cout << cnt;
return 0;
}

浙公网安备 33010602011771号