这次做的不够理想,过程磕磕绊绊,C题还是倒在第42个样例上(看了下WA的人,就数我最悲剧)......
A题:求所给角度(0--180)能否组成正多边形.。
套用内角公式(n - 2)* 180 / n ,则
a == 180.0 - (360.0/j)
j为边数
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int n;
double a;
while(cin >> n)
{
for(int i=0; i<n; i++)
{
cin >> a;
int ok = 0;
for(int j=2; j<=360; j++)
{
if(a == 180.0 - (360.0/j))
{
ok = 1;
break;
}
}
if(ok == 1)
{
cout << "YES" << endl;
}
else
cout << "NO" << endl;
}
}
return 0;
}
B题:
原先有一系列板块编号1-n,如有某个板块更新信息则占据首位,其他后移。给出刷新后位置由前到后的板块编号,问一定更新信息的板块有几个。
相邻两个板块i,i+1如果编号i > 编号i+1。说明板块i一定更新了,板块i+1却不一定。而板块i更新,排在板块i前面的,也是必定更新了。
这样问题就变成找最后一个满足板块编号i > 编号i+1的。
#include <iostream>
#include <cstdio>
using namespace std;
int a[100005];
int main()
{
int n;
while(cin >> n)
{
int t=0;
for(int i=1; i<=n; i++)
{
cin >> a[i];
}
for(int i=1; i<n; i++)
{
if(a[i] > a[i+1])
t = i;
}
cout << t << endl;
}
return 0;
}
C题:
Emuskald is a well-known illusionist. One of his trademark tricks involves a set of magical boxes. The essence of the trick is in packing the boxes inside other boxes.
From the top view each magical box looks like a square with side length equal to2k(kis
an integer,k ≥ 0) units. A magical boxvcan be
put inside a magical boxu, if side length ofvis
strictly less than the side length ofu. In particular, Emuskald can put 4 boxes of side length2k - 1into
one box of side length2k,
or as in the following figure:
Emuskald is about to go on tour performing around the world, and needs to pack his magical boxes for the trip. He has decided that the best way to pack them would be inside another magical box, but magical boxes are quite expensive to make. Help him find the
smallest magical box that can fit all his boxes.
Output
Output a single integerp, such that the smallest magical box that can contain all of Emuskald’s boxes has side length2p.
Note
Picture explanation. If we have 3 boxes with side length 2 and 5 boxes with side length 1, then we can put all these boxes inside a box with side length 4, for example, as shown in the picture.
In the second test case, we can put all four small boxes into a box with side length 2.
有一堆大大小小的箱子,小的能放大的里面,求另取一个边长最短的箱子,将这些箱子装下。具体规则就看题吧...
想法是将已有箱子按照边长由小到大排序,一个循环中,将较小的放入较大些的,如果较小的剩余,则剩余的小的箱子换算成较大的;如此递推,
再枚举能装下已有最大箱子最小的边长的箱子。 虽然考虑到了k范围实在是太大了而加上if(2 * box[i+1].len - 2 * box[i].len <= 32)剔除,但没注意等于
32也是超过范围的。所以去掉等号,就行了。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
struct BOX
{
long long len,num;
} box[100005];
bool cmp(BOX a, BOX b)
{
return a.len < b.len;
}
int main()
{
int n;
while(cin >> n)
{
for(int i=0; i<n; i++)
{
cin >> box[i].len >> box[i].num;
}
sort(box,box+n,cmp);
for(int i=0; i<n-1; i++)
{
if(2 * box[i+1].len - 2 * box[i].len < 32)
{
int t = ceil(box[i].num*1.0/((1 << (2*box[i+1].len -2 * box[i].len)))) - box[i+1].num;
if(t > 0)
box[i+1].num += t;
}
}
long long t = box[n-1].num;
int i;
for(i=1;; i++)
{
if(1 << (2 * i) >= t)
break;
}
cout << i + box[n-1].len << endl;
}
return 0;
}
赛后发现C题是div1的第一题,可见去div1就是挂零的节奏......长路漫漫啊!!!
分享到:
相关推荐
#include using namespace std; int main(){ int n,k,i,x,ans=0,q[20]; cin>>n>>k; for(i=1;i;++i){ cin>>x; q[4]=0; q[7]=0; while(x) { ++q[x]; x/=10; } if(q[4]+q[7])++ans; } ...}
codeforce701B题
解决问题的方法教育Codeforces回合101 - 2/6 常规托架顺序-接受红色和蓝色-接受Codeforces回合#686(Div.3) 2/6 特殊排列-接受唯一出价拍卖-接受序列转换-接受编号成序列-接受Codeforces回合#685(分区2) 2/7 减...
codeforce700B题
codeforce 701A题
codeforce700A题
Codeforce:针对第2分部的Codeforce的每一轮解决方案的说明
CodeForce 比赛# 标题解决方案25 一种 27 一种 320 乙 429 一种 586 C 608 C 615 C 624 C 626 一种 640 G 654 C 669 乙 愚人节d Croc_Champ_R2 乙
codeforce Rudolf and the Another Competition的C语言写法(用了sort)
_我解决的Codeforce问题的解决方案_ Python解决方案 一个 4 69 281 344 546 630 749 791 977 1196 1223 1433 C语言解决方案 一个 4 69 344 546 630 705 749 791 977 1223 C ++解决方案 一个 4 ...
我在Codeforce上解决的一些问题:) 使用的CPP模板: //作者:Dipjoy Basak // dip_10 使用命名空间std #include ; #define endl“ \ n” #define ll long long #define ld long double #define pb push_back #...
码力Codeforce解决方案
CodeForce 我提出的Codeforce问题
CodeForces问题解决方案:Codeforce问题解决方案。 专注于动态编程,数据结构,数论,图算法,二进制搜索
Codeforce:针对Codeforce上各种挑战的解决方案
程式设计有关Codeforce中存在的问题的C ++代码
CODEFORCE问题集解决方案
codeforces:Codeforce问题
codeforce_solutions:这是我的Codeforce练习集解决方案存储库