Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0094d9d

Browse files
new cf solutions
1 parent f8a8e8f commit 0094d9d

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <bits/stdc++.h>
2+
#define endl "\n"
3+
#define ll long long
4+
using namespace std;
5+
6+
int main(){
7+
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
8+
9+
ll k, n, w;
10+
cin >> k >> n >> w;
11+
12+
ll cost = 0, uni=0;
13+
for(int i=0; i<w; i++)
14+
cost += (uni+=k);
15+
16+
cout << max(0ll, cost - n) << endl;
17+
18+
return 0;
19+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <bits/stdc++.h>
2+
#define endl "\n"
3+
#define ll long long
4+
using namespace std;
5+
6+
const int MAXN = 5e6 + 4;
7+
ll ps[MAXN];
8+
9+
int main(){
10+
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
11+
12+
for(int i=2; i<MAXN; i++) if(!ps[i]){
13+
ps[i]++;
14+
for(int j=i+i, k; j<MAXN; j+=i){
15+
k = j;
16+
do {
17+
ps[j]++;
18+
k/=i;
19+
} while(k%i == 0);
20+
}
21+
}
22+
23+
// for(int i=0; i<20; i++) cerr << ps[i] << " "; cerr << endl;
24+
for(int i=1; i<MAXN; i++) ps[i] += ps[i-1];
25+
26+
int tt; cin >> tt;
27+
while(tt--)
28+
{
29+
int a, b;
30+
cin >> a >> b;
31+
32+
33+
cout << ps[a] - ps[b] << endl;
34+
}
35+
36+
return 0;
37+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /