点击题号进入题面

---------

新笔记本终于到了,可以愉快的写代码了..

------

A 807A

题意:

  给一个codeforces比赛的final standing和比赛前后的rating值,保证不存在一样的rating,

  问你是否能知道本场比赛是否计分,如果不能判断则输出maybe

分析:

  遍历即可

  有人变化直接输出rated,无人变化如果不是顺序则unrated,否则maybe

 /**********************
*@Name:
*
*@Author: Nervending
*@Describtion:
*@DateTime: 2018-02-04 03:39:20
***********************/
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
const int INF=0x3f3f3f3f;
int n;
int a[maxn];
int b[maxn];
int c[maxn];
int cmp(int a,int b){
return a>b;
}
int main(){
//#define test
#ifdef test
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
cin>>n;
for(int i=;i<n;i++){
cin>>a[i]>>b[i];
c[i]=a[i];
}
sort(c,c+n,cmp);
for(int i=;i<n;i++){
if(a[i]!=b[i]){
cout<<"rated";
return ;
}
}
for(int i=;i<n;i++){
if(a[i]>a[i-]){
cout<<"unrated";
return ;
}
}
cout<<"maybe"; #ifdef test
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return ;
}

------

B 807B

题意:

  在一场CF比赛中,需要至少达到y分,当前以及获得足够的x分,x>=y

  除此之外,为了获得奖品,你需要改变自己的分数使得当前分数x经过下列伪代码获得的名次值中存在你的当前名次a

  通过hack的成功和失败可以改变自己的分数x,成功加100失败减50

  求最小的成功次数,输入保证有解

i := (s div 50) mod 475
repeat 25 times:
i := (i * 96 + 42) mod 475
print (26 + i)

分析:

  枚举即可

  先尝试只失败不成功

  然后尝试成功,每次测试也尝试额外失败一次的情况

 /**********************
*@Name:
*
*@Author: Nervending
*@Describtion:
*@DateTime: 06/02/18 22:05
***********************/
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+;
const int maxm=1e6+;
const int INF=0x3f3f3f3f;
#define show(x) cout<<#x<<"="<<x<< endl
int a,x,y;
int check(int s){
int na=(s/)%;
for(int i=;i<;i++){
na=(na*+)%;
if(a==na+)return true;
}
return false;
} int main() {
//#define test
#ifdef test
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
cin>>a>>x>>y;
for(int i=x;i>=y;i-=){
if(check(i)){
cout<<;
return ;
}
}
for(int i=x+,j=;;j++,i+=){
if(check(i)||check(i-)){
cout<<j;
return ;
}
} #ifdef test
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return ;
}

-------

C 807C

题意;

  你当前的成功次数是x,总次数是y,你希望比值达到a/b,求最小的尝试次数,不存在输出-1

分析:

  可以发现,只需要总次数达到b的整数倍即可,最小的合法倍数必然为解

  成功次数只要为正值且小于总次数即可

  二分枚举倍数即可以获得答案

  注意是可能不存在解的,比如a==b而x!=y,或者a==0而x!=0,可以预先剪枝

 /**********************
*@Name:
*
*@Author: Nervending
*@Describtion:
*@DateTime:
***********************/
#include <bits/stdc++.h>
#define show(x) cout<<#x<<"="<<x<<endl
using namespace std;
const int maxn=1e5+;
const int maxm=1e6+;
const int INF=0x3f3f3f3f;
typedef long long ll;
typedef unsigned long long ull;
inline long long gcd(long long a,long long b){while(b)b=(a%b)+(a=b)-b;return a;}
inline long long lcm(long long a,long long b){return a*b/gcd(a,b);}
ll casn,n,m,k;
ll a,b,x,y; int main(){
//#define test
#ifdef test
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif cin>>casn;
while(casn--){
cin>>x>>y>>a>>b;
if((a==b&&x!=y)||(a==&&x!=)){
cout<<-<<endl;
continue;
}
ll ans=-;
ll l=,r=1e10;
while(l<=r){
ll mid=(l+r)>>;
ll ac=mid*a;
ll at=mid*b;
if(ac>=x&&at>=y&&ac-x<=at-y){
ans=at-y;
r=mid-;
}else {
l=mid+;
}
}
if(ans==-)cout<<-<<endl;
else cout<<ans<<endl;
} #ifdef test
fclose(stdin);
fclose(stdout);
system("out.txt");
#endif
return ;
}

codeforces 412div.2的更多相关文章

  1. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  2. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  3. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  4. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  5. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  6. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  7. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  8. CodeForces - 696B Puzzles

    http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...

  9. CodeForces - 148D Bag of mice

    http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...

随机推荐

  1. Linux记录-shell实现脚本监控服务器及web应用

    1.apache web 服务器 1 2 3 4 5 6 7 8 9 10 !/bin/bash # 表示请求链接3秒钟,不要返回的测试数据 nc -w 3 localhost 80 &> ...

  2. JAVA-集合类型List(ArrayList、LinkedList)常用操作例子(基础必备)

    package com.net.xinfang.reflect; import java.util.ArrayList; import java.util.Arrays; import java.ut ...

  3. PHP7 网络编程(三)孤儿进程与僵尸进程

    基本概念 我们知道在unix/linux中,正常情况下,子进程是通过父进程创建的,子进程在创建新的进程.子进程的结束和父进程的运行是一个异步过程,即父进程永远无法预测子进程 到底什么时候结束. 当一个 ...

  4. JAVA正确地自定义比较对象---如何重写equals方法和hashCode方法

    在实际应用中经常会比较两个对象是否相等,比如下面的Address类,它有两个属性:String province 和 String city. public class Address { priva ...

  5. C# string 保留数字英文字母

    using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressi ...

  6. shell 命令使用笔记

    1.提取字符串中以.ddd结尾的ddd值 result=$(echo "chip86.500" | grep -Eo '\.[0-9]{1,}' | grep -Eo '[0-9] ...

  7. 第28月第11天 vim -b

    1. 首先以二进制方式编辑这个文件:        vim -b datafile现在用 xxd 把这个文件转换成十六进制:        :%!xxd文本看起来像这样:        0000000 ...

  8. LOJ #2183「SDOI2015」序列统计

    有好多好玩的知识点 LOJ 题意:在集合中选$ n$个元素(可重复选)使得乘积模$ m$为$ x$,求方案数对$ 1004535809$取模 $ n<=10^9,m<=8000且是质数,集 ...

  9. Python 13 简单项目-堡垒机

    本节内容 项目实战:运维堡垒机开发 前景介绍 到目前为止,很多公司对堡垒机依然不太感冒,其实是没有充分认识到堡垒机在IT管理中的重要作用的,很多人觉得,堡垒机就是跳板机,其实这个认识是不全面的,跳板功 ...

  10. JAVA百度过的异常(1)

    1.---无法解析类型 javax.servlet.http.HttpServletRequest.从必需的 .class 文件间接引用了它 The type javax.servlet.http.H ...