Last active
August 29, 2015 14:11
-
-
Save akouryy/d6076a8d7e1003548e3a to your computer and use it in GitHub Desktop.
jmc.miz-miz.biz
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 <algorithm> | |
#include <climits> | |
#include <cstdio> | |
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <numeric> | |
#include <string> | |
#include <utility> | |
#include <vector> | |
using namespace std; | |
#define times(n, i) for(decltype(n) i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(decltype((f)+(t)) i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(decltype((f)+(t)) i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(decltype((f)+(t)) i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(decltype((f)+(t)) i = (f); i > (u); i--) | |
#define unless(c) if(!(c)) | |
#define until(c) while(!(c)) | |
#define loop while(1) | |
const long long INF = LLONG_MAX; | |
const int IINF = INT_MAX; | |
int main(){ | |
ios::sync_with_stdio(false); | |
int A, B, C, D; | |
cin >> A >> B >> C >> D; | |
cout << max((C * D - A * B - 1) / B + 1, 0) << endl; | |
} | |
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 <algorithm> | |
#include <climits> | |
#include <cstdio> | |
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <numeric> | |
#include <string> | |
#include <utility> | |
#include <vector> | |
using namespace std; | |
#define times(n, i) for(int i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(int i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(int i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(int i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(int i = (f); i > (u); i--) | |
#define unless(c) if(!(c)) | |
#define until(c) while(!(c)) | |
#define loop while(1) | |
const long long INF = LLONG_MAX; | |
const int IINF = INT_MAX; | |
int main(){ | |
ios::sync_with_stdio(false); | |
int N, C; | |
cin >> N >> C; | |
vector<int> people(100); | |
fill(people.begin(), people.end(), C); | |
times(N, i){ | |
int L, R; | |
cin >> L >> R; | |
L--; R--; | |
bool succeed = false; | |
upto(L, R, j){ | |
if(people[j]){ | |
people[j]--; | |
cout << j + 1 << endl; | |
succeed = true; | |
break; | |
} | |
} | |
unless(succeed) | |
cout << -1 << endl; | |
} | |
} | |
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 <algorithm> | |
//#include <array> | |
#include <climits> | |
#include <cstdio> | |
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <numeric> | |
#include <string> | |
#include <utility> | |
#include <vector> | |
using namespace std; | |
#define times(n, i) for(int i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(int i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(int i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(int i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(int i = (f); i > (u); i--) | |
/* | |
#define times(n, i) for(decltype(n) i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(decltype((f)+(t)) i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(decltype((f)+(t)) i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(decltype((f)+(t)) i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(decltype((f)+(t)) i = (f); i > (u); i--) | |
*/ | |
#define unless(c) if(!(c)) | |
#define until(c) while(!(c)) | |
#define loop while(1) | |
const long long INF = LLONG_MAX / 3; | |
const int IINF = INT_MAX / 3; | |
int main(){ | |
ios::sync_with_stdio(false); | |
int N; | |
int DC[2]; | |
cin >> N >> DC[1] >> DC[0]; | |
vector<int**> dp(N + 1); // [goal%2][now%2] | |
times(N + 1, i){ | |
dp[i] = new int*[2]; | |
times(2, j) dp[i][j] = new int[2]; | |
} | |
times(4, j) dp[0][j / 2][j % 2] = (-IINF) * (j % 2); | |
times(N, i){ | |
int A, B; | |
cin >> A >> B; | |
times(4, j){ | |
int val = dp[i][j / 2][(j + A) % 2] + DC[j / 2] - B; | |
dp[i + 1][j / 2][j % 2] = max(val, dp[i][j / 2][j % 2]); | |
} | |
} | |
cout << max(dp[N][0][0], dp[N][1][1]) << endl; | |
} |
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 <algorithm> | |
//#include <array> | |
#include <climits> | |
#include <cstdio> | |
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <numeric> | |
#include <string> | |
#include <utility> | |
#include <vector> | |
using namespace std; | |
#define times(n, i) for(int i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(int i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(int i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(int i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(int i = (f); i > (u); i--) | |
/* | |
#define times(n, i) for(decltype(n) i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(decltype((f)+(t)) i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(decltype((f)+(t)) i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(decltype((f)+(t)) i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(decltype((f)+(t)) i = (f); i > (u); i--) | |
*/ | |
#define unless(c) if(!(c)) | |
#define until(c) while(!(c)) | |
#define loop while(1) | |
const long long INF = LLONG_MAX / 3; | |
const int IINF = INT_MAX / 3; | |
int main(){ | |
ios::sync_with_stdio(false); | |
int N, M, P; | |
cin >> N >> M >> P; | |
vector<int> pyon(N); | |
fill(pyon.begin(), pyon.end(), -IINF); | |
pyon[P - 1] = 0; | |
times(M, i){ | |
int X; | |
cin >> X; | |
X--; | |
int px = pyon[X], px1 = pyon[X + 1]; | |
pyon[X] = max(px, px1 + 1); | |
pyon[X + 1] = max(px1, px + 1); | |
} | |
cout << pyon[0] << endl; | |
} | |
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 <algorithm> | |
//#include <array> | |
#include <climits> | |
#include <cstdio> | |
#include <functional> | |
#include <iostream> | |
#include <map> | |
#include <numeric> | |
#include <set> | |
#include <string> | |
#include <utility> | |
#include <vector> | |
using namespace std; | |
#define times(n, i) for(int i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(int i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(int i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(int i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(int i = (f); i > (u); i--) | |
/* | |
#define times(n, i) for(decltype(n) i = 0 ; i < (n); i++) | |
#define upto(f, t, i) for(decltype((f)+(t)) i = (f); i <= (t); i++) | |
#define downto(f, t, i) for(decltype((f)+(t)) i = (f); i >= (t); i--) | |
#define uptil(f, u, i) for(decltype((f)+(t)) i = (f); i < (u); i++) | |
#define downtil(f, u, i) for(decltype((f)+(t)) i = (f); i > (u); i--) | |
*/ | |
#define unless(c) if(!(c)) | |
#define until(c) while(!(c)) | |
#define loop while(1) | |
const long long INF = LLONG_MAX / 3; | |
const int IINF = INT_MAX / 3; | |
set<int> divisors(int n){ | |
set<int> divisors; | |
for(int x = 2; x * x <= n; x++){ | |
if(n % x == 0){ | |
divisors.insert(x); | |
divisors.insert(n / x); | |
} | |
} | |
return divisors; | |
} | |
map<int, int> pyon_; | |
int pyon(int n){ | |
if(pyon_.find(n) != pyon_.end()) | |
return pyon_[n]; | |
if(n == 1) return 1; | |
set<int> ds = divisors(n); | |
int sum = 1; | |
for(std::set<int>::iterator i = ds.begin(); i != ds.end(); i++){ | |
sum += pyon(*i); | |
sum %= 100000; | |
} | |
return sum; | |
} | |
int main(){ | |
ios::sync_with_stdio(false); | |
int N; | |
cin >> N; | |
cout << pyon(N) << endl; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment