#include<algorithm> #include<cmath> #include<cstring> #include<iostream> #include<map> #include<queue> #include<stack> #include<vector> typedeflonglong ll; #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define endl '\n' usingnamespace std; intmain() { // IOS; int k = 9; //进制 string num = "2022"; //数字 int ans = 0; ll temp = 1; int len = num.size(); for (int i = len - 1; i >= 0; --i) { ans += temp * (num[i] - '0'); temp *= k; } cout << ans; return0; }
评测用例规模与约定
对于 50% 的评测用例,$1 ≤ a, b, n ≤ 10^6$
对于 100% 的评测用例,$1 ≤ a, b, n ≤ 10^{18}$
思路
略
AC代码
#include<algorithm> #include<cmath> #include<cstring> #include<iostream> #include<map> #include<queue> #include<stack> typedeflonglong ll; #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define endl '\n' usingnamespace std;
intmain() { IOS; ll a, b, n; cin >> a >> b >> n; ll ans = n / (5 * a + 2 * b) * 7; ll t = ans / 7 * (5 * a + 2 * b); for (int i = 1; i <= 7; i++) { if (t >= n) break; if (i < 6) t += a, ans++; else t += b, ans++; } cout << ans << endl;
#include<algorithm> #include<cmath> #include<cstring> #include<iostream> #include<map> #include<queue> #include<stack> typedeflonglong ll; #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define endl '\n' usingnamespace std;
intmain() { IOS; int n; cin >> n; for (int i = 1; i <= n; i++) cout << 2 * max(n - i, i - 1) << endl; return0; }
#include<algorithm> #include<cmath> #include<cstring> #include<iostream> #include<map> #include<queue> #include<stack> #include<vector> typedeflonglong ll; #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define endl '\n' usingnamespace std; constint N = 510; int a[N][N], b[N][N]; intmain() { IOS; int n, m, k; ll ans = 0; cin >> n >> m >> k; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; b[i][j] = b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1] + a[i][j]; } } for (int l = 1; l <= m; l++) //枚举矩阵的左边 { for (int r = l; r <= m; r++) //枚举矩阵的右边 { for (int i = 1, j = 1; i <= n; i++) //有了左右边界,从上到下扫描 { while (j <= i && (b[i][r] - b[i][l - 1] - b[j - 1][r] + b[j - 1][l - 1]) > k) j++; if (j <= i) //有可能最小的矩阵都不满足,此时j>i ans += (i - j + 1); } } } cout << ans << endl; return0; }
#include<algorithm> #include<cmath> #include<cstring> #include<iostream> #include<map> #include<queue> #include<stack> #include<vector> typedeflonglong ll; #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define endl '\n' usingnamespace std; constint N = 1e7 + 10; constint mod = 1e9 + 7;
#include<algorithm> #include<cmath> #include<cstring> #include<iostream> #include<map> #include<queue> #include<stack> typedeflonglong ll; #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define max(a, b) (a > b ? a : b) #define min(a, b) (a < b ? a : b) #define endl '\n' usingnamespace std; constint mod = 1e9 + 7; constint N = 110; int dp[N][N][N]; //三维分别为店、花、酒 intmain() { IOS; int n, m; cin >> n >> m; dp[0][0][2] = 1; //初始状态 for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { for (int k = 0; k <= m; k++) {