QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#404977#3004. It's a Mod, Mod, Mod, Mod WorldLspeed#TL 0ms0kbC++141.7kb2024-05-05 05:23:562024-05-05 05:23:56

Judging History

你现在查看的是最新测评结果

  • [2024-05-05 05:23:56]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-05-05 05:23:56]
  • 提交

answer

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("trapv")
#pragma GCC target("avx2")
#define x first
#define y second
#define eb emplace_back
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define sz(x) (int)(x).size()
#define make_unique(x) sort(all(x)), (x).erase(unique(all(x)), (x).end())

using namespace std;

typedef long long i64;
//typedef __int128 i128;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<i64> vl;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<i64,i64> pll;
typedef tuple<int,int,int> iii;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

int readInt() { int a; scanf("%d",&a); return a; }
i64 readLong() { i64 a; scanf("%lld",&a); return a; }
char readChar() { char a; scanf(" %c",&a); return a; }
double readDouble() { double a; scanf(" %lf",&a); return a; }
void readString(char *s) { scanf(" %s",s); }

const int mod = 998244353;
int add(int a, int b) { return ((a+=b)>=mod) ? a-mod:a; }
int mul(int a, int b) { return a*1ll*b%mod; }
int pw(int a, int b) {
	int ans = 1, res = a;
	for(int i = 1; i <= b; i*=2, res=mul(res,res)) {
		if(i&b) {
			ans = mul(ans, res);
		}
	}
	return ans;
}

void solve() {
	int p = readInt();
	int q = readInt();
	int n = readInt();

	p %= q;

	i64 sum = 0;
	int cur = 0;
	for(int i = 1; i <= n; ++i) {
		cur += p;
		if(cur >= q) cur -= q;
		sum += cur;
	}
	printf("%lld\n",sum);
}

int main() {

	int q = readInt();
	while(q--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

91125
999956 999956 999956
999956 999956 999957
999956 999956 999958
999956 999956 999959
999956 999956 999960
999956 999956 999961
999956 999956 999962
999956 999956 999963
999956 999956 999964
999956 999956 999965
999956 999956 999966
999956 999956 999967
999956 999956 999968
999956 999956 999969
...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
499956500946
499956500946
499957500902
499958500857
499959500811
499960500764
499961500716
499962500667
499963500617
499964500566
499965500514
499966500461
499967500407
499968500352
499969500296
499970500239
49...

result: