【CF套題】Codeforces Round #524 (Div. 2) (1080A~F)
原題地址
迴歸
,這場堪堪上紫。
A.Petya and Origami
【題目大意】
一本筆記本有
頁,每個筆記本只能染成紅綠藍其中一種顏色,需要
頁紅色,
頁綠色,
張藍色,問最少需要多少本筆記本。
【解題思路】
顏色不相關,分開計算即可。
【參考程式碼】
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,ans;
int read()
{
int ret=0,f=1;char c=getchar();
while(!isdigit(c)) {if(c=='-')f=0;c=getchar();}
while(isdigit(c)) ret=ret*10+(c^48),c=getchar();
return f?ret:-ret;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("A.in","r",stdin);
freopen("A.out","w",stdout);
#endif
n=read();k=read();
ans=(ll)(n*2-1)/k+1+(ll)(n*5-1)/k+1+(ll)(n*8-1)/k+1;
printf("%lld\n",ans);
return 0;
}
B.Margarite and the best present
【題目大意】
數列
,
求
,
【解題思路】
差分求字首和,每兩個元素看成一組計算即可。
【參考程式碼】
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll q,l,r,ans;
int read()
{
int ret=0,f=1;char c=getchar();
while(!isdigit(c)) {if(c=='-')f=0;c=getchar();}
while(isdigit(c)) ret=ret*10+(c^48),c=getchar();
return f?ret:-ret;
}
ll calc(ll x)
{
if(x%2==0) return x/2;
return x/2-x;
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("B.in","r",stdin);
freopen("B.out","w",stdout);
#endif
q=read();
while(q--)
{
ll l=read(),r=read();
ans=calc(r)-calc(l-1);
printf("%lld\n",ans);
}
return 0;
}
C.Masha and two friends
【題目大意】
一個
的國際象棋棋盤,左下角為白格,接下來將棋盤的一個矩形所有格染白,再將另一個矩形所有格染黑,問白格和黑格各有多少個,多組資料。
【解題思路】
計算出每個矩形對應原始棋盤的多少個黑格及白格,容斥計算即可。
【參考程式碼】
#include<bits/stdc++.h>
#define mkp make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
ll n,m;
pii ans;
ll read()
{
ll ret=0,f=1;char c=getchar();
while(!isdigit(c)) {if(c=='-')f=0;c=getchar();}
while(isdigit(c)) ret=ret*10+(c^48),c=getchar();
return f?ret:-ret;
}
struct point{ll x,y;};
struct node
{
point a,b;
node(){}
node(ll x,ll y,ll xx,ll yy){a.x=x;a.y=y;b.x=xx;b.y=yy;}
void init(){a.x=read();a.y=read();b.x=read();b.y=read();}
}p1,p2,emp;
pii operator -(const pii&x,const pii &y){return mkp(x.fi-y.fi,x.se-y.se);}
pii operator +(const pii&x,const pii &y){return mkp(x.fi+y.fi,x.se+y.se);}
pii calc(ll x,ll y)
{
if(!x || !y) return mkp(0,0);
if((ll)x*y%2==0) return mkp((ll)x*y/2,(ll)x*y/2);
return mkp((ll)x*y/2+1,(ll)x*y/2);
}
pii get(const point &a,const point &b){return calc(b.x,b.y)-calc(b.x,a.y-1)-calc(a.x-1,b.y)+calc(a.x-1,a.y-1);}
ll getsize(const point &a,const point &b){return (ll)(b.x-a.x+1)*(b.y-a.y+1);}
node getmerge(node a,node b)
{
if(a.a.x>b.a.x) swap(a,b);
if(b.a.x>a.b.x) return emp;
if(b.b.y<a.a.y) return emp;
if(b.a.y>a.b.y) return emp;
return node(max(a.a.x,b.a.x),max(a.a.y,b.a.y),min(a.b.x,b.b.x),min(a.b.y,b.b.y));
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("C.in","r",stdin);
freopen("C.out","w",stdout);
#endif
int T=read();emp=node(-1,-1,-1,-1);
while(T--)
{
n=read();m=read();
p1.init();p2.init();
pii t1=calc(n,m),t2=get(p1.a,p1.b),t3=get(p2.a,p2.b);
node tmp=getmerge(p1,p2);
//tmp.write();
if(tmp.a.x==-1)
{
ans.fi=t1.fi-t2.fi-t3.fi+getsize(p1.a,p1.b);
ans.se=t1.se-t2.se-t3.se+getsize(p2.a,p2.b);
}
else
{
pii t4=get(tmp.a,tmp.b);
ans.fi=t1.fi-t2.fi-t3.fi+t4.fi+getsize(p1.a,p1.b)-getsize(tmp.a,tmp.b);
ans.se=t1.se-t2.se-t3.se+t4.se+getsize(p2.a,p2.b);
}
printf("%lld %lld\n",ans.fi,ans.se);
}
return 0;
}
D.Olya and magical square
【題目大意】
初始有一個邊長為
的正方形,進行
次操作,每次選擇一個正方形,將它分成四個等大的正方形。問是否能在
次操縱後從左下角的正方形走到右上角的正方形,且經過的正方形邊長一樣,多組資料。
【解題思路】
假設最後路徑一定是貼著左、上邊界,我們只需要列舉答案,然後判斷是否可行即可。判斷可行計算出答案需要至少切多少刀以及最多能切多少刀,可以發現答案一定很小(不到
吧)。
【參考程式碼】
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
int T,n
相關推薦
【CF套題】Codeforces Round #524 (Div. 2) (1080A~F)
原題地址 迴歸
CF
\text {CF}
CF,這場堪堪上紫。
A.Petya and Origa
【CF套題】Codeforces Round #528 (Div. 1)
【前言】 並不能打div2的我十分絕望。 雖然上分了還是很高興。
【題目】 原題地址
A.Connect Three
將三個格子按
x
Codeforces Round #524 (Div. 2)(前3題題解)
這場比賽手速場+數學場,像我這樣讀題都讀不大懂的蒟蒻表示呵呵呵。
第四題搞了半天,大概想出來了,但來不及(中途家裡網炸了)查錯,於是我交了兩次丟了100分。幸虧這次沒有掉rating。
比賽傳送門:https://codeforces.com/contest/1080。
A.Petya
【尤拉路】Codeforces Round #508 (Div. 2) E. Maximum Matching
Step1 Problem:
給你 n 個塊,每個塊左右兩邊有顏色,中間是塊的權值,如果不同的塊的邊顏色一樣,那麼它們可以合併成新的一塊。
例:兩個塊分別是 c1 v1 c2, c2 v2 c1,那麼這兩個塊可以變成 c1 v1+v2 c1,或者
C. Queen Codeforces Round #549 (Div. 2) (搜索)
down pop ger puts ESS wiki closed sca graphic ---恢復內容開始---
You are given a rooted tree with vertices numerated from 11 to nn . A tree
【CF套題】Educational Codeforces Round 57
【前言】 打了小號,做到心態爆炸,雖然最後過了6T。 然而十分後悔為什麼沒有用大號打,大號打就上橙了qwq。
【題目】 原題地址
A.Find Divisible
輸出
l
【做題】Codeforces Round #453 (Div. 1) D. Weighting a Tree——拆環
每一個 int 會有 while sig 實現 dex -s 怎麽辦 前言:結論題似乎是我的硬傷……
題意是給你一個無向圖,已知連接到每一個點的邊的權值和(為整數,且屬於區間[-n,n]),需要求出每條邊權值的一個合法解(都要是在區間[-2*n^2,2*n^2]內的整數)。
【Codeforces Round #524(Div. 2)】Olya and magical square(思維+數學推導)
題目連結
D. Olya and magical square
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standar
【CF套題】 Gym101623 NWERC2017
【前言】 在BZOJ上翻題看到了幾題,心血來潮就全寫了。 C這個搜尋我不是很會寫,直接看了別人的(然而還是沒寫) 然後這個J讓我知道一定不能在還要用值的時候刪掉一個指標。
【題目】 原題地址
A.Ascending Photo
單獨寫。
B.Boss Battle
顯
【CF套題】Good Bye 2018
【前言】 自閉了,四題以後就看著排名一直往下掉。 E想了個線段樹維護階梯,沒看wiki,出來才發現是公式題。 F想了個凸包,結果是個貪心。 心態炸裂(然而rk500還能漲分)
【題目】 原題地址
A.New Year and the Christmas Ornament
瞎搞
【動態規劃】 Codeforces Round #416 (Div. 2) C. Vladik and Memorable Trip
and main spa def esp 動態 return 價值 can 劃分那個序列,沒必要完全覆蓋原序列。對於劃分出來的每個序列,對於某個值v,要麽全都在該序列,要麽全都不在該序列。
一個序列的價值是所有不同的值的異或和。整個的價值是所有劃分出來的序列的價值之和。
【分類討論】【spfa】【BFS】Codeforces Round #416 (Div. 2) D. Vladik and Favorite Game
邊界情況 code def bfs spa eof scan string amp 那個人第一步肯定要麽能向下走,要麽能向右走。於是一定可以判斷出上下是否對調,或者左右是否對調。
然後他往這個方向再走一走就能發現一定可以再往旁邊走,此時就可以判斷出另一個方向是否對調。
都判
【動態規劃】Codeforces Round #406 (Div. 2) C.Berzerk
[1] space node sca 一個 for 隊列 ber 動態規劃 有向圖博弈問題。
能轉移到一個必敗態的就是必勝態。
能轉移到的全是必勝態的就是必敗態。
轉移的時候可以用隊列維護。
可以看這個 http://www.cnblogs.com/quintessence
【推導】Codeforces Round #364 (Div. 2) D. As Fast As Possible
std %d while pre 分享 mage oss 時間 http
一種方法是二分總時間,復雜度O(nlogn)。
另外我們可以證明,當所有人同時到達終點的時候,是最優的,因為沒有人的時間“浪費”了。
我們又發現,每個人的運動過程總是兩段,要麽是走路,要麽是坐車。於
【排序】【規律】Codeforces Round #254 (Div. 2) - D. Rooter's Song
names nes rac then represent cin loaded output same D. DZY Loves FFT
Source
http://codeforces.com/contest/445/problem/D
Description
Wh
【思維】Codeforces Round #485 (Div. 2) B. High School: Become Human(對數)
space scanf CA ace ima AC bsp ont http 題目鏈接:http://codeforces.com/contest/987/problem/B
在運算的時候取對數就好了
1 #include <bits/stdc++
【偽暴力+智商剪枝】Codeforces Round #489 (Div. 2) D
profile 接下來 時間 一個數 鏈表 數字 sum 方式 print 失蹤人口突然回歸……orz。題解還是有必要寫的,雖然估計只有自己(?自己也不一定看得懂)看得懂。
題目鏈接:http://codeforces.com/contest/992/problem/D
【Codeforces】Codeforces Round #492 (Div. 2) [Thanks, uDebug!] (Contest 996)
spl === bsp -- href 分享 printf cli 位置 題目
傳送門:QWQ
A:A - Hit the Lottery
分析:
大水題 模擬
代碼:
#include <bits/stdc++.h&g
Codeforces Round #524 (Div. 2) B. Margarite and the best present 規律題
B. Margarite and the best present
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
stand
【codeforces】Codeforces Round #523 (Div. 2)
目錄
【B. Views Matter】貪心
【C. Multiplicity】dp+滾動陣列
【D. TV Shows】貪心
【B. Views Matter】
題目連結:https://codeforces.com/contest/1061/problem/B