結果

問題 No.2233 Average
ユーザー hamamonhamamon
提出日時 2023-03-03 22:27:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 790 ms / 2,000 ms
コード長 4,904 bytes
コンパイル時間 4,651 ms
コンパイル使用メモリ 258,716 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 23:29:14
合計ジャッジ時間 10,178 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 456 ms
6,940 KB
testcase_09 AC 701 ms
6,944 KB
testcase_10 AC 411 ms
6,944 KB
testcase_11 AC 398 ms
6,944 KB
testcase_12 AC 351 ms
6,944 KB
testcase_13 AC 77 ms
6,940 KB
testcase_14 AC 380 ms
6,940 KB
testcase_15 AC 518 ms
6,940 KB
testcase_16 AC 147 ms
6,940 KB
testcase_17 AC 189 ms
6,944 KB
testcase_18 AC 790 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif

using LL = long long;
using VI = vector<int>;
using VL = vector<LL>;
using VS = vector<string>;
using VC = vector<char>;
using VB = vector<bool>;
using VVI = vector<vector<int>>;
using VVL = vector<vector<LL>>;
using VVS = vector<vector<string>>;
using VVC = vector<vector<char>>;
using VVB = vector<vector<bool>>;
using SI = set<int>;
using PII = pair<int, int>;
const LL LINF = 1e18;
const int IINF = 1e9;
 
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl 
#define out(a) cout << a << endl
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define rrep(i, a, b) for (int i = a; i >= (int)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const double PI = acos(-1);
const VI DX = {-1, 0, 1, 0};
const VI DY = {0, 1, 0, -1};

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool IsPrime(LL num){if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) if (num % i == 0) return false; return true;}
LL fact(LL n) { LL res = 1; while (n > 1) res *= n--; return res; } //factorial
map<LL,LL> decomp(LL N){map<LL,LL> res; LL num=N; for(LL i=2;i*i<=num;i++){while(N%i==0) N/=i,res[i]++; if(N==1) break;} if(N!=1) res[N]++; return res;}
bool isNumber(string s){for(auto c : s){if (isdigit(c))continue;else return false;}return true;} //if string is number then true, otherwise false
LL n_ary_str(string s, int n){LL ans = 0; for(char x:s){ans *= n; ans += x - '0';} return ans;}
LL n_ary_VI(VI arr, int n){LL ans = 0;rep(i, 0, arr.size()){ans *= n;ans += arr[i];} return ans;}
int GCD(int a, int b){if(b==0){return a;}else{return GCD(b,a%b);}}
int LCM(int a, int b){return(a/GCD(a,b))*b;}
VI split_digit(int a){VI res;string s=to_string(a);for(auto c:s){res.push_back(c-'0');}return res;}
LL power(int a,int b){LL res=1;rep(i,0,b){res*=a;}return res;}
int ctoi(char c){return c-'0';}
VS VStrans(VS a){int h = a.size(); int w = a[0].size(); VS b(w, string(h, '?')); rep(i, 0, h){ rep(j, 0, w){b[j][i] = a[i][j];}} return b;}
VVI VVItrans(VVI a){VVI b(a.size(), VI(a[0].size())); rep(i, 0, a.size()){rep(j, 0, a[i].size()){b[j][i] = a[i][j];}} return b;}
VVC VVCtrans(VVC a){VVC b(a.size(), VC(a[0].size())); rep(i, 0, a.size()){rep(j, 0, a[i].size()) b[j][i] = a[i][j];} return b;}
int VVImin(VVI a){int res = IINF;rep(i,0,a.size()){res=min(res,*min_element(all(a[i])));}return res;}
int VVImax(VVI a){int res = 0;rep(i,0,a.size()){res=max(res,*max_element(all(a[i])));}return res;}
VL get_divisors(LL n){vector<LL>ret;for(LL i=1;i*i<=n;i++){if(n%i==0){ret.push_back(i);if(i*i!=n)ret.push_back(n/i);}}sort(ret.begin(),ret.end());return ret;}

bool Sfind(string s,string tgt){if(s.find(tgt)!=string::npos)return true;else return false;}
bool VIfind(VI a,int tgt){if(count(all(a),tgt))return true;else return false;}
bool VVIfind(VVI a,int tgt){for(auto A:a){if(VIfind(A,tgt))return true;}return false;}
bool VCfind(VC a,char tgt){if(count(all(a),tgt))return true;else return false;}
bool VVCfind(VVC a,char tgt){for(auto A:a){if(VCfind(A,tgt))return true;}return false;}
bool VSfind(VS a,string tgt){if(count(all(a),tgt))return true;else return false;}
bool VVSfind(VVS a,string tgt){for(auto A:a){if(VSfind(A,tgt))return true;}return false;}
bool VBfind(VB a,bool tgt){if(count(all(a),tgt))return true;else return false;}
bool VVBfind(VVB a,bool tgt){for(auto A:a){if(VBfind(A,tgt))return true;}return false;}

void VScout(VS a){rep(i,0,a.size()){cout<<a[i]<<endl;}}
void VIcout(VI a){rep(i,0,a.size())cout<<a[i]<<" ";cout<<endl;}
void VLcout(VL a){rep(i,0,a.size())cout<<a[i]<<" ";cout<<endl;}
void VVIcout(VVI a){rep(i,0,a.size()){VIcout(a[i]);}}
void VVLcout(VVL a){rep(i,0,a.size()){VLcout(a[i]);}}
void VCcout(VC a){rep(i,0,a.size())cout<<a[i]<<' ';cout<<endl;}
void VVCcout(VVC a){rep(i,0,a.size()){VCcout(a[i]);}}
void VBcout(VB a){rep(i,0,a.size()){if(a[i])cout<<"o ";else cout<<"x ";}cout<<endl;return;}
void VVBcout(VVB a){rep(i,0,a.size())VBcout(a[i]);return;}
void SIcout(SI st){for(auto s:st){cout<<s<<" ";}cout<<endl;}

int main() {
    int t; cin >> t;
    while(t--){
        LL a, b, c, k; cin >> a >> b >> c >> k;
        VVL dp(101, VL(3));
        dp[0][0] = a;
        dp[0][1] = b;
        dp[0][2] = c;
        rep(i, 1, 101){
            dp[i][0] = (dp[i-1][1] + dp[i-1][2]) / 2;
            dp[i][1] = (dp[i-1][0] + dp[i-1][2]) / 2;
            dp[i][2] = (dp[i-1][0] + dp[i-1][1]) / 2;
        }
        LL ans = 0;
        rep(j, 0, 3){
            ans += dp[min(k, (LL)100)][j];
        }
        printf("%lld\n", ans);
    }
    return 0;
}
0