A - Rating Goal


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the rating of the user (not necessarily an integer) changes according to the performance of the user, as follows:

  • Let the current rating of the user be a.
  • Suppose that the performance of the user in the contest is b.
  • Then, the new rating of the user will be the avarage of a and b.

For example, if a user with rating 1 competes in a contest and gives performance 1000, his/her new rating will be 500.5, the average of 1 and 1000.

Takahashi's current rating is R, and he wants his rating to be exactly G after the next contest.
Find the performance required to achieve it.

Constraints

  • 0≤R,G≤4500
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

R
G

Output

Print the performance required to achieve the objective.


Sample Input 1

Copy
2002
2017

Sample Output 1

Copy
2032

Takahashi's current rating is 2002.
If his performance in the contest is 2032, his rating will be the average of 2002 and 2032, which is equal to the desired rating, 2017.


Sample Input 2

Copy
4500
0

Sample Output 2

Copy
-4500

Although the current and desired ratings are between 0 and 4500, the performance of a user can be below 0.

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
using namespace std; const int N = + ; int c, n;
struct node{
int total_time = , total_solve = , num;
map<int, int> state;
}Node[N]; int main(){
double a, b;
cin >> a >> b;
cout << b * - a <<endl;
}

B - Addition and Multiplication


Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

Square1001 has seen an electric bulletin board displaying the integer 1. He can perform the following operations A and B to change this value:

  • Operation A: The displayed value is doubled.
  • Operation B: The displayed value increases by K.

Square1001 needs to perform these operations N times in total. Find the minimum possible value displayed in the board after N operations.

Constraints

  • 1≤N,K≤10
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

N
K

Output

Print the minimum possible value displayed in the board after N operations.


Sample Input 1

Copy
4
3

Sample Output 1

Copy
10

The value will be minimized when the operations are performed in the following order: A, A, B, B.
In this case, the value will change as follows: 1 → 2 → 4 → 7 → 10.


Sample Input 2

Copy
10
10

Sample Output 2

Copy
76

The value will be minimized when the operations are performed in the following order: A, A, A, A, B, B, B, B, B, B.
In this case, the value will change as follows: 1 → 2 → 4 → 8 → 16 → 26 → 36 → 46 → 56 → 66 → 76.

By the way, this contest is AtCoder Beginner Contest 076.

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
using namespace std; int main(){
int n, k;
int a = ;
cin >> n >> k;
for(int i = ; i <= n; i++){
if(a + k < * a) a += k;
else a *= ;
}
cout << a << endl;
}
#include<bits/stdc++.h>

using namespace std;

int n, k;

int DFS(int n, int val){
if(n == ) return val;
int a = DFS(n - , val * );
int b = DFS(n - , val + k);
return a > b ? b : a;
}
int main(){
cin >> n >> k;
cout << DFS(n, ) << endl;
}

C - Dubious Document 2


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

E869120 found a chest which is likely to contain treasure.
However, the chest is locked. In order to open it, he needs to enter a string S consisting of lowercase English letters.
He also found a string S', which turns out to be the string S with some of its letters (possibly all or none) replaced with ?.

One more thing he found is a sheet of paper with the following facts written on it:

  • Condition 1: The string S contains a string T as a contiguous substring.
  • Condition 2: S is the lexicographically smallest string among the ones that satisfy Condition 1.

Print the string S.
If such a string does not exist, print UNRESTORABLE.

Constraints

  • 1≤|S'|,|T|≤50
  • S' consists of lowercase English letters and ?.
  • T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T'

Output

Print the string S.
If such a string does not exist, print UNRESTORABLE instead.


Sample Input 1

Copy
?tc????
coder

Sample Output 1

Copy
atcoder

There are 26 strings that satisfy Condition 1: atcoderbtcoderctcoder,..., ztcoder. Among them, the lexicographically smallest is atcoder, so we can say S=atcoder.


Sample Input 2

Copy
??p??d??
abc

Sample Output 2

Copy
UNRESTORABLE

There is no string that satisfies Condition 1, so the string S does not exist.

#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
string s, t;
set<string> S; void Work(){
int lens = s.size();
int lent = t.size();
for(int i = ; i < lens; i++){
if(s[i] == '?' || s[i] == t[]){
string tmp = s;
for(int j = ; j < i; j++) if(tmp[j] == '?') tmp[j] ='a';
bool can = false;
for(int j = ; j < lent; j++){
if(tmp[i+j]!= '?' && tmp[i+j] != t[j]) break;
tmp[i+j] = t[j];
if(j == lent - ) can = true;
}
if(can){
for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';
S.insert(tmp);
}
}
}
if(S.size() == ) cout << "UNRESTORABLE" << endl;
else cout << *S.begin() << endl;
}
int main(){
cin >> s >> t;
Work();
}

AtCoder Beginner Contest 076的更多相关文章

  1. AtCoder Beginner Contest 100 2018/06/16

    A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E8 ...

  2. AtCoder Beginner Contest 052

    没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder ...

  3. AtCoder Beginner Contest 053 ABCD题

    A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has ...

  4. AtCoder Beginner Contest 136

    AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using na ...

  5. AtCoder Beginner Contest 137 F

    AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) ...

  6. AtCoder Beginner Contest 079 D - Wall【Warshall Floyd algorithm】

    AtCoder Beginner Contest 079 D - Wall Warshall Floyd 最短路....先枚举 k #include<iostream> #include& ...

  7. AtCoder Beginner Contest 064 D - Insertion

    AtCoder Beginner Contest 064 D - Insertion Problem Statement You are given a string S of length N co ...

  8. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle【暴力】

    AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle 我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环....我自己写怎么都 ...

  9. AtCoder Beginner Contest 075 C bridge【图论求桥】

    AtCoder Beginner Contest 075 C bridge 桥就是指图中这样的边,删除它以后整个图不连通.本题就是求桥个数的裸题. dfn[u]指在dfs中搜索到u节点的次序值,low ...

随机推荐

  1. 哈密尔顿环x

    欧拉回路是指不重复地走过所有路径的回路,而哈密尔顿环是指不重复地走过所有的点,并且最后还能回到起点的回路.  代码如下: #include<iostream> #include<cs ...

  2. R & and &&

    https://blog.csdn.net/jining11/article/details/84933110 和C中的&不用,不要用&&,一般情况都是用&表示并且

  3. 原生Js_使用setInterval() 方法实现图片轮播功能

    用javascript图片轮播功能 <!DOCTYPE html> <html> <head> <meta charset="utf-8" ...

  4. Java基础__Java中常用数学类Math那些事

     测试 package Cynical_Gary; public class Cynical_Text { public static void main(String[] args){ System ...

  5. [CSP-S模拟测试]:五子棋(模拟)

    题目传送门(内部题122) 输入格式 输入文件第一行为一个正整数$n$,表示双方总共下了多少步棋. 接下来$n$行,输入文件每行两个正整数.第$i$行的两个数$x,y$表示第$i$步的棋子下在了第$x ...

  6. 关于synchronized和ReentrantLock之多线程同步详解

    一.线程同步问题的产生及解决方案 问题的产生: Java允许多线程并发控制,当多个线程同时操作一个可共享的资源变量时(如数据的增删改查),将会导致数据不准确,相互之间产生冲突. 如下例:假设有一个卖票 ...

  7. ImportError: bad magic number in: b'\x03\xf3\r\n'

    解决办法:删除项目中所有的 .pyc 文件.

  8. 正向代理与反向代理以及Nginx【总结】(转)

    今天在了解Nginx的时候,涉及到反向代理的问题,看到一篇博文写的清晰明了,转载记录一下,后续继续学习,再次感谢博主的分享. 原文地址:https://www.cnblogs.com/Anker/p/ ...

  9. SpringMVC restful风格下载文件,文件后缀被截掉

    原文:https://blog.csdn.net/wisdomhealth/article/details/78400421 @RequestMapping("/file/{filename ...

  10. WPF复杂形状按钮

    方法很简单,将图片转换为<path>就可以了(需要用到Photoshop) 不过一般情况下制作按钮都不会用到这种方法,通常只要用image填充一张图片或者把路径转成按钮控件就可以了. 之所 ...