Codeforces Round #521 (Div. 3) A. Frog Jumping
題解
題目大意 一個人從0開始偶數向右走a 奇數向左走b 問k次走多遠
偶數部分b和a抵消了一部分 奇數再加一個a即可
AC程式碼
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{
#ifdef LOCAL
freopen("C:/input.txt", "r", stdin);
#endif
int T;
cin >> T;
while (T--)
{
ll a, b, k;
cin >> a >> b >> k;
ll ans = (a - b) * (k / 2);
ans += (k % 2) * a;
cout << ans << endl;
}
return 0;
}
相關推薦
Codeforces Round #521 (Div. 3) A. Frog Jumping
題解 題目大意 一個人從0開始偶數向右走a 奇數向左走b 問k次走多遠 偶數部分b和a抵消了一部分 奇數再加一個a即可 AC程式碼 #include <stdio.h> #include <bits/stdc++.h> using namespace
Codeforces Round #521 (Div. 3) A 模擬 B 貪心 C模擬 D 二分 E 二分+排序
A Code: #include <bits/stdc++.h> #define LL long long using namespace std; int main(){ int T ; cin >> T ; int a , b , k ;
Codeforces Round #521 (Div. 3) A B C D E
A. Frog Jumping 題目連結:https://codeforces.com/contest/1077/problem/A 題目大意:t組測試資料,從0開始,向前跳a,向後跳b,跳k次,輸出最後所在的位置。 題解:大水題,直接輸出就行了 int main() { std:
Codeforces Round #521 (Div. 3) A 模擬 B 貪心 C模擬 D 二分 E 二分+排序
A Code: #include <bits/stdc++.h> #define LL long long using namespace std; int main(){ int T
Codeforces Round #486 (Div. 3) A. Diverse Team
pre table ngs href AI pop ons NPU school Codeforces Round #486 (Div. 3) A. Diverse Team 題目連接: http://codeforces.com/contest/988/problem/
Codeforces Round #501 (Div. 3) A Points in Segments
segments ble round show 默認 () for using pre 翻譯 現在有一個數軸,上面會有\(M\)個點,標號為\(1\)到\(N\),現在給你在數軸上的條\(N\)線段的起始與終止的點,問哪幾個點沒有被這樣線段覆蓋,從小到大輸出。 思路 簽到題
Codeforces Round #515 (Div. 3) A(思維)
題意:找1~L之間 v 的倍數的個數,在區間[l,r]之間的不能算 思路:1到n之間v的倍數個數為n/v向下取整,因為是閉區間,所以區間裡v的倍數個數為r/v-(l-1)/v,l為什麼要減一?因為l-1/v是1到l-1中v的倍數個數。 #include<bits/stdc++.h>
CodeForces Round #498 Div.3 A. Adjacent Replacements
http://codeforces.com/contest/1006/problem/A Mishka got an integer array aa of length nn as a birthday present (what a surp
Codeforces Round #521 (Div. 3) D. Cutting Out 【二分+排序】
任意門:http://codeforces.com/contest/1077/problem/D D. Cutting Out time limit per test 3 seconds memory limit per test 25
Codeforces Round #521 (Div. 3) CDE
C 問刪掉在陣列中一個數後,剩下的陣列中,是否存在一個數時其它所有數的和。 遍歷每一個數,假設刪掉它後,剩下的數中取一個最大值,看他的值是不是陣列之和的一半,是的話就成立。 1 #include <bits/stdc++.h> 2 #define ll long long 3
Codeforces Round #521 (Div. 3)
題目連結:http://codeforces.com/contest/1077 A.Frog Jumping 解題思路:作差再判斷最後是否還需再一次向右跳即可。 AC程式碼: 1 #include<bits/stdc++.h> 2 using namespace std;
codeforces1077C Good Array(Codeforces Round #521 (Div. 3))
傳送門:http://codeforces.com/contest/1077/problem/C 吐槽:忘記特判2的情況被hack了,肥宅大哭.jpg 程式碼: #include<cstdio> #include<cmath> #include<algo
Codeforces Round #521 (Div. 3) D - Cutting Out(二分答案)
D. Cutting Out time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You a
Codeforces Round #521 Div. 3 玩耍記
A:簽到。 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> #include<cstring> #include<algo
Codeforces Round #521 (Div. 3) E. Thematic Contests
題解 題目大意 每天完成若干個相同的任務 第二天完成的數量要求是前一天的兩倍 不同天不能完成相同的任務 問最大任務完成數量 統計相同編號的數量 向前做字首和 暴力列舉最後一次的完成數量 每次除以二檢測當前數量-天數(減去向前字首和的貢獻)是否大於0 大於則滿足 每次結束檢測是否為奇數
Codeforces Round #521 (Div. 3) D. Cutting Out
題解 題目大意 給你一個序列 讓你找到一個長度為k的序列 在原序列當中出現的次數最多 滿足單調性 二分出現次數 然後根據出現次數隨意輸出一個序列 AC程式碼 #include <stdio.h> #include <bits/stdc++.h> usi
Codeforces Round #521 (Div. 3) B. Disturbed People
題解 題目大意 n個燈0關燈1開燈 101則中間的睡不著 問最少關掉多少個燈可以全都能睡著 遇見101則將後面的1的燈泡關掉 這樣解決10101的問題 計數輸出即可 AC程式碼 #include <stdio.h> #include <bits/stdc++
CodeForces Round #521 (Div.3) C. Good Array
sum true copy sam pan have ++ cond math http://codeforces.com/contest/1077/problem/C Let‘s call an array good if there is an element i
CodeForces Round #521 (Div.3) C. Good Array
http://codeforces.com/contest/1077/problem/C Let's call an array good if there is an element in the array that equals to the sum of a
Codeforces Round #521 (Div. 3) D
自己手撕WA 19 #include<iostream> #include<stdio.h> #include<queue> #include<algorithm> using namespace std; int a[200010]; int a