A题:
#include <bits/stdc++.h> using namespace std; int main () { int n; cin >> n; cout << "L" << string(n, 'o') << "ng" << endl; return 0; }
B题:
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int a[N]; int main () { int n; cin >> n; int i = 0; while (n != 0) { ++i; a[i] = n % 2; n /= 2; } //for (int j = i; j >= 1; j--) cout << a[j]; int ans = 0; for (int j = 1; j <= i; j++) { if (a[j] != 0) { break; } ans++; } cout << ans << endl; return 0; }
C题:
#include <bits/stdc++.h> using namespace std; const int N = 1e7 + 10; long long int a[N]; int main () { long long int n, m = 1; scanf ("%lld", &n); if (n == 1) { cout << 0 << endl; return 0; } long long int i = 0; n -= 1; while (n != 0) { ++i; a[i] = n % 5 * 2; n /= 5; } for (long long int j = i; j >= 1; j--) { cout << a[j]; } cout << endl; return 0; }
D题:
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; long long int a[N]; long long int b[N], c[N]; long long int ans[N]; int main () { long long int n; cin >> n; for (long long int i = 1; i <= n; i++) { cin >>a[i]; } for (long long int i = 1; i <= n; i++) { //if (i == 1) a[i - 1] = 1; b[i] = min (a[i], b[i - 1] + 1); } for (long long int i = n; i >= 1; i--) { //if (i == n) a[i + 1] = 1; c[i] = min (a[i], c[i + 1] + 1); ans[i] = min (c[i], b[i]); } sort (ans + 1, ans + 1 + n); cout << ans[n]; return 0; }
标签:AtCoder,cout,int,代码,namespace,long,abc336,ans,main From: https://www.cnblogs.com/thjblogs/p/17991338