QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#115027#5850. Candy Store__stick27 ✓11ms3428kbC++141.6kb2023-06-24 14:23:482023-06-24 14:23:49

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-24 14:23:49]
  • 评测
  • 测评结果:27
  • 用时:11ms
  • 内存:3428kb
  • [2023-06-24 14:23:48]
  • 提交

answer

// Problem: A - Candy Store
// Contest: Virtual Judge - Training 20230624
// URL: https://vjudge.net/contest/564820#problem/A
// Memory Limit: 1024 MB
// Time Limit: 1000 ms
// start time: 2023-06-24 12:05:03

#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
using namespace std;
template<typename T>
inline bool cmax(T&x,const T& y){return x<y?x=y,1:0;}
template<typename T>
inline bool cmin(T&x,const T& y){return y<x?x=y,1:0;}
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vii; 
typedef unsigned long long ull;
#define sz(x) (int(x.size()))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define em emplace
#define X first
#define Y second
const int mod=998244353;
inline void MOD(int&x){x-=mod,x+=x>>31&mod;}
inline void MOD(ll& x){x-=mod,x+=x>>63&mod;}
inline int add(int x,int y){MOD(x+=y);return x;}
inline int mul(int x,int y){return 1ll*x*y%mod;}
template<typename ... A>inline int mul(const int& x,const A&... p){return 1ll*x*mul(p...)%mod;}
inline ll ksm(ll a,ll p=mod-2){ll ans=1;for(;p;p>>=1,a=a*a%mod)if(p&1)ans=ans*a%mod;return ans;}
typedef long double LD;
const int MAXN=2e5+10;
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(10);
	int T;cin>>T;
	for(int id=1;id<=T;id++)
	{
		int k;ll c;cin>>k>>c;
		ll sum=0;
		int ans=0;
		for(ll i=1;i<=c;i=sum/k+1)
		{
			ll dt=k-sum/i;
			sum+=dt*i,ans+=dt;
		}
		cout<<"Case #"<<id<<": ";
		cout<<ans<<'\n';
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 0ms
memory: 3412kb

input:

100
2 3
3 3
13 1
20 2
6 3
5 3
3 1
7 2
15 1
4 3
1 1
14 3
1 3
17 1
10 2
12 2
9 1
14 1
5 2
6 3
13 2
18 2
17 3
2 3
18 3
16 1
19 2
17 1
11 3
20 3
3 1
8 3
7 3
18 1
11 2
20 3
7 2
4 3
1 2
7 2
10 1
17 3
5 2
14 1
2 1
3 1
4 1
17 2
8 2
5 1
18 1
8 1
15 3
10 2
6 2
20 1
15 3
1 3
3 2
17 1
14 1
3 2
9 3
16 3
15 2
12 ...

output:

Case #1: 4
Case #2: 6
Case #3: 13
Case #4: 30
Case #5: 11
Case #6: 10
Case #7: 3
Case #8: 11
Case #9: 15
Case #10: 8
Case #11: 1
Case #12: 26
Case #13: 2
Case #14: 17
Case #15: 15
Case #16: 18
Case #17: 9
Case #18: 14
Case #19: 8
Case #20: 11
Case #21: 20
Case #22: 27
Case #23: 32
Case #24: 4
Case #...

result:

ok 100 lines

Subtask #2:

score: 20
Accepted

Test #2:

score: 20
Accepted
time: 11ms
memory: 3428kb

input:

100
984 4
830 901580635835
937 117926240831
1000 62009
1000 11
656 187600851857
577 732239839666
149 276944
401 126493510574
1000 696570219424
765 796394824105
422 120213965166
686 140
1000 431774067439
106 351578631166
374 279760528652
1 1000000000000
1000 134489424902
25 909266561260
402 333089014...

output:

Case #1: 2050
Case #2: 23340
Case #3: 24441
Case #4: 11617
Case #5: 3021
Case #6: 17420
Case #7: 16110
Case #8: 1960
Case #9: 10495
Case #10: 27860
Case #11: 21419
Case #12: 11023
Case #13: 3790
Case #14: 27381
Case #15: 2892
Case #16: 10087
Case #17: 40
Case #18: 26215
Case #19: 717
Case #20: 10911...

result:

ok 100 lines

Extra Test:

score: 0
Extra Test Passed