Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC optimize("O3")
- #include <bits/stdc++.h>
- using namespace std;
- #define int long long
- #define double long double
- #define _FastIO ios_base::sync_with_stdio(0); cin.tie(0)
- bool pal(string a){
- string b = a;
- reverse(b.begin() , b.end());
- return a == b;
- }
- bool pal(int n){
- int rev = 0 , old = n;
- while(n){
- rev = rev * 10 + n % 10;
- n /= 10;
- }
- return rev == old;
- }
- /*
- 123
- 0
- 3
- 32
- 321
- */
- signed main()
- {
- _FastIO;
- /*
- // A
- int n;
- string s;
- cin >> n >> s;
- int cnt = 0 , ans = 0;
- for(char i : s){
- if(i == 'I')
- cnt++;
- else
- cnt--;
- ans = max(ans , cnt);
- }
- cout << ans << '\n';
- */
- /*
- // B
- string s;
- cin >> s;
- int n = s.size();
- int a , z;
- for(int i = 0; i < n; i++){
- if(s[i] == 'A'){
- a = i;
- break;
- }
- }
- for(int i = n - 1; i >= 0; i--){
- if(s[i] == 'Z'){
- z = i;
- break;
- }
- }
- cout << z - a + 1 << '\n';
- //cout << s.rfind("Z") - s.find("A") + 1 << '\n';
- */
- /*
- // C
- int n;
- cin >> n;
- for(int i = 1; i <= 15; i++){
- int k = (int)powl(i , i);
- if(k == n){
- cout << i << '\n';
- return 0;
- }
- }
- cout << -1 << '\n';
- */
- /*
- // D
- int a , b;
- cin >> a >> b;
- int ans = 0;
- for(int i = a; i <= b; i++){
- ans += pal(i);
- }
- cout << ans << '\n';
- */
- /*
- // E
- string s;
- cin >> s;
- int n = s.size();
- int ans = LLONG_MAX;
- for(int i = 0; i + 2 < n; i++){
- int x = stoll(s.substr(i , 3));
- ans = min(ans , abs(x - 753));
- }
- cout << ans << '\n';
- */
- /*
- // F
- int n , m , k , x;
- cin >> n >> m;
- map<int , int> cnt;
- for(int i = 0; i < n; i++){
- cin >> k;
- while(k--){
- cin >> x;
- cnt[x]++;
- }
- }
- int ans = 0;
- for(auto i : cnt)
- ans += i.second == n;
- cout << ans << '\n';
- */
- /*
- // G
- int n , a , b , c;
- cin >> n >> a >> b >> c;
- int ans = LLONG_MAX;
- for(int i = 0; i <= 20; i++){ // 6
- for(int j = 0; j <= 20; j++){ // 8
- for(int k = 0; k <= 20; k++){ // 12
- int eggs = i * 6 + j * 8 + k * 12;
- if(eggs >= n)
- ans = min(ans , a * i + b * j + c * k);
- }
- }
- }
- cout << ans << '\n';
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement