Codeforces 1260 ABC
DEF 题对于 wyh 来说过于毒瘤,十分不可做。
A. Heating
Description:
给定\(a,b\),将\(b\)分成至少\(a\)个正整数,使这些正整数的平方和最小。
Solution:
sb题,3minA掉,但是提交代码花了我近20min
Code:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int T;
int a,b;
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&a,&b);
if(a>b){printf("%d\n",b);continue;}
int ans=(b%a)*(b/a+1)*(b/a+1)+(a-b%a)*(b/a)*(b/a);
printf("%d\n",ans);
}
return 0;
}
B. Obtain Two Zeroes
Description:
给定\(a,b\)和两种变化规则:
\]
或
\]
问能不能将\(a,b\)都变成0
Solution:
对 mod 3 余数讨论即可。
Code:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
ll T;
ll a,b;
int main()
{
cin>>T;
while(T--)
{
cin>>a>>b;
if(a>b) swap(a,b);
if((a*2-b)%3||a*2<b) printf("NO\n");
else printf("YES\n");
}
return 0;
}
C. Infinite Fence
Description:
给定\(a,b,k\),将a的倍数涂成红色,b的倍数涂成蓝色,a和b的公倍数随便涂,问是否存在一种方案,使得将涂色的数字从小到大排序后,不存在连续k个数是同一种颜色。
Solution:
结论:将\(a\)与\(b\)同除以\(gcd(a,b)\),结果不变。
这样我们就可以使\(a,b\)互质。假设\(a<=b\),然后判断啊\(a*(k-1)+1\)与\(b\)的关系就行了。具体见代码。
Code:
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
ll T,r,b,k;
ll gcd(ll a,ll b)
{
if(!b) return a;
return gcd(b,a%b);
}
int main()
{
scanf("%lld",&T);
while(T--)
{
scanf("%lld%lld%lld",&r,&b,&k);
ll g=gcd(r,b);r/=g;b/=g;if(r>b) swap(r,b);
if(r*(k-1)+1>=b) printf("OBEY\n");
else printf("REBEL\n");
}
return 0;
}
Codeforces 1260 ABC的更多相关文章
- codeforces CF475 ABC 题解
Bayan 2015 Contest Warm Up http://codeforces.com/contest/475 A - Bayan Bus B - Strongly Connected Ci ...
- Codeforces 802 ABC. Heidi and Library
题目大意 你需要保证第\(i\)天时有第\(a_i\)种书.你可以在任何一天买书,买第\(i\)种书的代价为\(c_i\). 你最多同时拥有\(k\)本书,如果此时再买书,则必须先扔掉已拥有的一本书. ...
- [CF787D]遗产(Legacy)-线段树-优化Dijkstra(内含数据生成器)
Problem 遗产 题目大意 给出一个带权有向图,有三种操作: 1.u->v添加一条权值为w的边 2.区间[l,r]->v添加权值为w的边 3.v->区间[l,r]添加权值为w的边 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) 【ABC】
老年人题解,语言python3 A - Bank Robbery 题意:给你ABC,以及n个数,问你在(B,C)之间的数有多少个. 题解:对于每个数判断一下就好了嘛 x,y,z = map(int,i ...
- Codeforces Round #247 (Div. 2) ABC
Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431 代码均已投放:https://github.com/illuz/Wa ...
- Codeforces Round #313 (Div. 2) ABC
A http://codeforces.com/contest/560/problem/A 推断给出的数能否组成全部自然数. 水题 int a[1010]; bool b[1000010]; int ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...
- Codeforces Round #312 (Div. 2) ABC题解
[比赛链接]click here~~ A. Lala Land and Apple Trees: [题意]: AMR住在拉拉土地. 拉拉土地是一个很漂亮的国家,位于坐标线.拉拉土地是与著名的苹果树越来 ...
随机推荐
- Spark原理概述
原文来自我的个人网站:http://www.itrensheng.com/archives/Spark_basic_knowledge 一. Spark出现的背景 在Spark出现之前,大数据计算引擎 ...
- 1011 World Cup Betting
Title:1011 World Cup Betting 1. 注意点 比较简单,没有注意点 2. python3代码 def func(output): max = 0 index = -1 lin ...
- Git创建和删除标签
创建标签 标签是一个让人容易记住的有意义的名字,它跟某个commit绑在一起.在Git中打标签非常简单,首先,切换到需要打标签的分支上,然后,敲命令git tag <name>就可以打一个 ...
- openresty-component
1.Array Var Nginx Module ArrayVarNginxModulelocation /foo { array_split ',' $arg_files to=$array; # ...
- 吴裕雄 python 人工智能——智能医疗系统后台用户注册、登录和初诊简约版代码展示
#用户注册.登录模块 #数据库脚本 CREATE TABLE usertable( userid number(8) primary key not null , username varchar(5 ...
- CSS 绝对定位时,水平居中而不影响原文档中其它元素
div.absolutemiddle { position: absolute; left: 50%; transform: translate(-50%); /* 平移50%为自身尺寸的一半,实现水 ...
- Spring的简单介绍
struts2:web层hibernate:dao层spring:service层 1 spring框架概述 1.1 什么是springSpring是一个开源框架,Spring是于2003 年兴起的一 ...
- 10,html全局属性有哪些
10,html全局属性(global attribute,html属性赋予元素意义和语境,html全局属性可以用于任何的html元素)有哪些 class:为元素设置类标识 data-*:为元素增加自定 ...
- [JLOI2009]神秘的生物
题目链接 题目大意 给定一个\(n*n\)的矩阵,从其中选取恰好一个连通块,使选取的格子所对应的权值和最大. \(n\leq 9\) 解题思路 由于\(n\)特别小,考虑插头dp. 和一般的插头dp不 ...
- 前端必学---JavaScript数据结构与算法---简介
前端必学---JavaScript数据结构与算法---简介 1. 数据结构: 数据结构是相互之间存在一种或者多种特定关系的数据元素的集合.---<大话数据结构> 1.1 数据结构的分类 1 ...