https://codeforces.com/contest/1272
A题 。。年轻人老想不一样的姿势。。。折腾半天直接枚举不香吗? 呸, 真香
B题。。。没仔细看题 WA到自闭
C题。。题目都告诉公式 n*(n+1)/2 了, 折腾半天发现不是 2^n-1不是组合数-{n,0} 然后推出 题目给的公式可还行, 对自己服气哦可真是棒呢
D题。。。有思路但是没写出来, 时间不够。。。。
A题, 直接枚举吧, 已有几种不一样的姿势提供
B题
//Recently you have bought a snow walking robot and brought it home
//so the rebot should come back to the home(0, 0)
//and notice you can't visit one point twice(except 0,0)
// ans += string(x, 'c'); //string copy x chars 'c'
C题, 模拟跑一遍
#include <bits/stdc++.h>//cf605 div3 #define ll long long #define _rep(i,a,b) for(int i = (a); i <= (b) ;i++) #define _for(i,a,b) for(int i = (a); i < (b) ;i++) using namespace std; void taskA(){ int q; cin >> q; while(q--){ int a[4]; cin >> a[1] >> a[2] >> a[3]; sort(a+1, a+4); ll ans = a[2]-a[1]+a[3]-a[1]+a[3]-a[2]; if(a[3]-a[1]<=2) ans = 0; for(int i = 4; i > 0; i--) if(ans-i > 0) {ans -= i; break;} cout << ans << endl; }return; }
void taskA1(){ int q,a,b,c; cin >> q; while(q--){ cin >> a >>b >> c; ll ans= 1e18; _rep(i,-1,1) _rep(j,-1,1) _rep(k,-1,1){ int x = a+i; int y = b+j; int z = c+k; ans = min(ans, (ll)(abs(x-y)+abs(y-z)+abs(x-z))); } cout << ans << endl; }return; } void taskA2(){ int t; cin >> t; while(t--){ int a[4]; cin >> a[1] >> a[2] >> a[3]; sort(a+1, a+4); int mx = max(0, a[3]-a[1]-2); cout << mx*2 << endl; }return; }
void taskB(){ int t; cin >> t; while(t--){ string s; cin >> s; int a[27] = {}; for(char ch : s) a[ch-'A']++; int cl = min(a['L'-'A'], a['R'-'A']); int cu = min(a['U'-'A'], a['D'-'A']); if(!cl || !cu) cl = min(cl, 1), cu = min(cu, 1); string ans = ""; //cout << "cl = " << cl << " cu = " << cu << endl; ans += string(cu, 'U');//_for(i,0,cu) ans += 'U'; ans += string(cl, 'L');//_for(i,0,cl) ans += 'L'; ans += string(cu, 'D');//_for(i,0,cu) ans += 'D'; ans += string(cl, 'R');//_for(i,0,cl) ans += 'R'; if(ans.size() == 0){ cout << "0\n\n"; continue;} cout << ans.size() << endl << ans << endl; }return; }
void taskC(){ int n,k; cin >> n >> k; string s; cin >> s; vector<int> used(27, 0); for(int i = 0; i < k; i++) { char ch; cin >> ch; cin.get(); used[ch-'a'] = 1; //cout << "ch = " << ch << endl; } ll ans = 0, cnt = 0; for(int i = 0; i < n; i++) { if(!used[s[i]-'a']) { if(cnt > 0) ans += (cnt*(cnt+1)/2); cnt = 0; } else cnt++; } if(cnt > 0) ans += (cnt*(cnt+1)/2); cout << ans << endl; return; }
void taskC1(){ int n,k; cin >> n >>k; string s; cin >> s; vector<int> v(27,0); _for(i,0,k) { char ch;; cin >> ch; cin.get();v[ch-'a'] = 1;} ll ans = 0; _for(i,0,n){ int pos = i; while(v[s[i]-'a']) i++; ans += 1LL*(i-pos)*(i-pos+1)/2; }cout << ans << endl; return; }
int main(){ //taskA(); taskB(); //taskC(); //taskC1(); //taskD(); return 0; }