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. Centos7 ISCSI配置 完全攻略

    Centos7 ISCSI配置 完全攻略 一. iscsi简单介绍 iSCSI( Internet Small Computer System Interface 互联网小型计算机系统接口) iscs ...

  2. 安慰奶牛Cheering up the Cow

    传送门 一次a就很开心 可以当作kruskal模板题(orz --------------------------------------------------------------------- ...

  3. MYSQL命令练习及跳过数据库密码进行密码重新设置

        2.看当前所有数据库:show databases; 3.进入mysql数据库:use mysql; 4.查看mysql数据库中所有的表:show tables; 5.查看user表中的数据: ...

  4. JavaScript中的typeof 和instanceof

    Js中的instanceof 和typeof的区别 演示1 var v5=new Number("22"); document.write(typeof v5+"< ...

  5. leetcode菜鸡斗智斗勇系列(9)--- Range Sum of BST

    1.原题: https://leetcode.com/problems/range-sum-of-bst/ Given the root node of a binary search tree, r ...

  6. ZOJ1008 Gnome Tetravex

    DFS+剪枝~ #include<bits/stdc++.h> using namespace std; ][]; int N; int cnt; ]; ]; unordered_map& ...

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

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

  8. Servlet的基本使用

    1.pom.xml导入包 <dependency> <groupId>javax.servlet</groupId> <artifactId>javax ...

  9. linux的数据盘挂载

    图文教程: Linux的云服务器数据盘未做分区和格式化,可以根据以下步骤进行分区以及格式化操作. 一:登陆 用Linux 的SSH 登陆软件(xshell 或者putty) 登陆阿里云主机服务器. 二 ...

  10. mysql修改字符集为utf8

    https://zhidao.baidu.com/question/1642165712897935220.html