Created
December 4, 2020 04:25
-
-
Save zzNuAzz/2f353d424415305f910aa7d86fda753e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
const int nmax = 21; | |
int main() { | |
int n; | |
cin >> n; | |
int a[nmax]; | |
int b[nmax]; | |
for(int i = 0; i < n; i++) { | |
cin >> a[i] >> b[i]; | |
} | |
for(int i = 0; i < n - 1; i++) { | |
for(int j = i+1; j < n; j++) { | |
if(a[i] < a[j]) { | |
int ta = a[i]; int tb = b[i]; | |
a[i] = a[j]; b[i] = b[j]; | |
a[j] = ta; b[j] = tb; | |
} | |
} | |
} | |
int f[nmax]; | |
f[0] = 1; | |
int lmax = 1; | |
for(int i = 1; i < n; i++) { | |
int max = 0; | |
for(int j = 0; j < i; j++) { | |
if(b[j] > b[i] && a[j] > a[i]&& f[j] > max) max = f[j]; | |
} | |
f[i] = max + 1; | |
if (f[i] > lmax) lmax = f[i]; | |
} | |
cout << lmax; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
const int maxn = 11; | |
const int maxf = 1001; | |
const int inf = 999999; | |
int main() { | |
freopen("testcase", "r", stdin); | |
int c, n; | |
cin >> c >> n; | |
int a[maxn]; | |
int f[maxf]; | |
for(int i = 1; i <= n; i++) { | |
cin >> a[i]; | |
} | |
for(int i = 0; i <= n; i++) { | |
for(int j = 0; j <= c; j++) { | |
if(j == 0) f[j] = 0; | |
else if(i == 0) f[j] = inf; | |
else f[j] = min(f[j], f[j - a[i]] + 1); | |
} | |
} | |
cout << f[c]; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() | |
{ | |
int L, R, digit; | |
cin >> L >> R >> digit; | |
vector<bool> isPrime(R - L + 1, true); | |
for (int i = 2; i * i <= R; ++i) { | |
for (int j = max(i * i, (L + i - 1) / i * i); j <= R; j += i) { | |
isPrime[j - L] = false; | |
} | |
} | |
if (1 >= L) { | |
isPrime[1 - L] = false; | |
} | |
int ans = 0; | |
for (int x = L; x <= R; ++x) { | |
if (isPrime[x - L]) { | |
int t = x; | |
while(t > 0) { | |
if(t % 10 == digit) { | |
ans++; | |
break; | |
} | |
t /= 10; | |
} | |
} | |
} | |
cout << ans; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment