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=a−x , b=b−2x
\]

\[a=a−2x , b=b−x
\]

问能不能将\(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的更多相关文章

  1. codeforces CF475 ABC 题解

    Bayan 2015 Contest Warm Up http://codeforces.com/contest/475 A - Bayan Bus B - Strongly Connected Ci ...

  2. Codeforces 802 ABC. Heidi and Library

    题目大意 你需要保证第\(i\)天时有第\(a_i\)种书.你可以在任何一天买书,买第\(i\)种书的代价为\(c_i\). 你最多同时拥有\(k\)本书,如果此时再买书,则必须先扔掉已拥有的一本书. ...

  3. [CF787D]遗产(Legacy)-线段树-优化Dijkstra(内含数据生成器)

    Problem 遗产 题目大意 给出一个带权有向图,有三种操作: 1.u->v添加一条权值为w的边 2.区间[l,r]->v添加权值为w的边 3.v->区间[l,r]添加权值为w的边 ...

  4. 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 ...

  5. 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 ...

  6. Codeforces Round #247 (Div. 2) ABC

    Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431  代码均已投放:https://github.com/illuz/Wa ...

  7. Codeforces Round #313 (Div. 2) ABC

    A http://codeforces.com/contest/560/problem/A 推断给出的数能否组成全部自然数. 水题 int a[1010]; bool b[1000010]; int ...

  8. 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 ...

  9. Codeforces Round #312 (Div. 2) ABC题解

    [比赛链接]click here~~ A. Lala Land and Apple Trees: [题意]: AMR住在拉拉土地. 拉拉土地是一个很漂亮的国家,位于坐标线.拉拉土地是与著名的苹果树越来 ...

随机推荐

  1. Python - 定时动态获取IP代理池,存放在文件中

    定时功能通过module time + 死循环实现,因为time.sleep()会自动阻塞 get_ip_pool.py """ @__note__: while Tru ...

  2. 使用php-vmstat遇到的麻烦

    workerman-vmstat是一个基于workerman的扩展,用于监听服务器应用对内存.cpu消耗的友好的查看功能,具体介绍可以去git上看:    https://github.com/wal ...

  3. ajax循环展示某段代码

    ajax内定义function,根据条件递归调用即可. success: function(data){ if (dataList[i].subModuleList){ sublist(dataLis ...

  4. 总结String类的常用方法

    总结String类的常用方法 1. 获取字符串长度 public int length() 2. 获取字符串某一位置的字符 public char charAt(int index) 注意:字符串中第 ...

  5. C语言:有序递增链表的插入问题。

    //已建立一个带头节点的单向链表,链表中的各结点按结点数据域中的数据递增有序连接.fun函数:把形参x的值放入一个新结点并插入链表中,使插入的各个数据域的数据仍保持递增有序. #include < ...

  6. 不要在mutation回调函数之外,修改vuex仓库里属性的状态

    [vuex] do not mutate vuex store state outside mutation handlers. import * as types from './mutation- ...

  7. 重磅消息,Micrium的uCOS全家桶将推出免费商业授权

    说明: 1.预计将在下个月末的Embedded World 2020正式宣布开源免费商用. 2.uCOS全家桶一旦宣布免费商用,将给那些还在收费的RTOS带来一波冲击.其中最值的关注的是去年微软收购T ...

  8. python3实现在二叉树中找出和为某一值的所有路径

    在二叉树中找出和为某一值的所有路径请写一个程序创建一棵二叉树,并按照一定规则,输出二叉树根节点到叶子节点的路径.规则如下:1.从最顶端的根结点,到最下面的叶子节点,计算路径通过的所有节点的和,如果与设 ...

  9. Spring Boot Ftp Client 客户端示例支持断点续传

    本章介绍 Spring Boot 整合 Ftpclient 的示例,支持断点续传 本项目源码下载 1 新建 Spring Boot Maven 示例工程项目 注意:是用来 IDEA 开发工具 File ...

  10. 连接mysql,oracle的命令 以及导入sql文件

    Oracle 1,sqlplus  username/password 导入: 2,@后面跟着sql文件的路径,回车,导入数据 @D:/test.sql; 导入完毕,输入commit; MySQL: ...