A - Addition and Subtraction Easy


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

Joisino wants to evaluate the formula "A op B". Here, A and B are integers, and the binary operator op is either + or -. Your task is to evaluate the formula instead of her.

Constraints

  • 1≦A,B≦109
  • op is either + or -.

Input

The input is given from Standard Input in the following format:

A op B

Output

Evaluate the formula and print the result.


Sample Input 1

Copy
1 + 2

Sample Output 1

Copy
3

Since 1+2=3, the output should be 3.


Sample Input 2

Copy
5 - 7

Sample Output 2

Copy
-2

解法:没什么好说的

#include<bits/stdc++.h>
using namespace std;
map<int,int>q;
long long h,m;
char s;
int main()
{
scanf("%lld %c %lld",&h,&s,&m);
if(s=='+')
{
printf("%lld\n",h+m);
}
else
{
printf("%lld\n",h-m);
}
return ;
}

B - Contest with Drinks Easy


Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

Joisino is about to compete in the final round of a certain programming competition. In this contest, there are N problems, numbered1 through N. Joisino knows that it takes her Ti seconds to solve problem i(1≦iN).

Also, there are M kinds of drinks offered to the contestants, numbered 1 through M. If Joisino takes drink i(1≦iM), her brain will be stimulated and the time it takes for her to solve problem Pi will become Xi seconds. It does not affect the time to solve the other problems.

A contestant is allowed to take exactly one of the drinks before the start of the contest. For each drink, Joisino wants to know how many seconds it takes her to solve all the problems if she takes that drink. Here, assume that the time it takes her to solve all the problems is equal to the sum of the time it takes for her to solve individual problems. Your task is to write a program to calculate it instead of her.

Constraints

  • All input values are integers.
  • 1≦N≦100
  • 1≦Ti≦105
  • 1≦M≦100
  • 1≦PiN
  • 1≦Xi≦105

Input

The input is given from Standard Input in the following format:

N
T1 T2 TN
M
P1 X1
P2 X2
:
PM XM

Output

For each drink, calculate how many seconds it takes Joisino to solve all the problems if she takes that drink, and print the results, one per line.


Sample Input 1

Copy
3
2 1 4
2
1 1
2 3

Sample Output 1

Copy
6
9

If Joisino takes drink 1, the time it takes her to solve each problem will be 11 and 4 seconds, respectively, totaling 6 seconds.

If Joisino takes drink 2, the time it takes her to solve each problem will be 23 and 4 seconds, respectively, totaling 9 seconds.


Sample Input 2

Copy
5
7 2 3 8 5
3
4 2
1 7
4 13

Sample Output 2

Copy
19
25
30
题意:告诉你原始的做题时间,现在可以喝饮料,改变对应一个题的做题时间,问按顺序喝饮料,求总的做题时间(每次喝饮料都不影响上下数据,依次独立)
解法:模拟
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long t[];
long long p;
struct P
{
long long x,y;
}He[];
int main()
{
cin>>n;
for(int i=;i<=n;i++)
{
cin>>t[i];
}
cin>>m;
for(int i=;i<=m;i++)
{
cin>>He[i].x>>He[i].y;
}
for(int i=;i<=m;i++)
{
long long sum=;
for(int j=;j<He[i].x;j++)
{
sum+=t[j];
// cout<<sum<<"A"<<endl;
}
sum+=He[i].y;
// cout<<sum<<"B"<<endl;
for(int j=He[i].x+;j<=n;j++)
{
sum+=t[j];
// cout<<sum<<"C"<<endl;
}
cout<<sum<<endl;
}
return ;
}

C - Lining Up


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

There are N people, conveniently numbered 1 through N. They were standing in a row yesterday, but now they are unsure of the order in which they were standing. However, each person remembered the following fact: the absolute difference of the number of the people who were standing to the left of that person, and the number of the people who were standing to the right of that person. According to their reports, the difference above for person i is Ai.

Based on these reports, find the number of the possible orders in which they were standing. Since it can be extremely large, print the answer modulo 109+7. Note that the reports may be incorrect and thus there may be no consistent order. In such a case, print 0.

Constraints

  • 1≦N≦105
  • 0≦AiN−1

Input

The input is given from Standard Input in the following format:

N
A1 A2 AN

Output

Print the number of the possible orders in which they were standing, modulo 109+7.


Sample Input 1

Copy
5
2 4 4 0 2

Sample Output 1

Copy
4

There are four possible orders, as follows:

  • 2,1,4,5,3
  • 2,5,4,1,3
  • 3,1,4,5,2
  • 3,5,4,1,2

Sample Input 2

Copy
7
6 4 0 2 4 0 2

Sample Output 2

Copy
0

Any order would be inconsistent with the reports, thus the answer is 0.


Sample Input 3

Copy
8
7 5 1 1 7 3 5 3

Sample Output 3

Copy
16
题意:没读懂
解法:首先判断不成立的,当然是出现数字三次以上就算不合法(0不能出现两次以上),然后统计每个数字出现两次的数量,求2^n%mod即可
#include<bits/stdc++.h>
using namespace std;
long long n;
map<long long,long long>q;
map<long long,long long>::iterator it;
long long modl(long long a, long long b, long long c) //快速幂取余a^b%c
{
long long res, t;
res = % c;
t = a % c;
while (b)
{
if (b & )
{
res = res * t % c;
}
t = t * t % c;
b >>= ;
}
return res;
}
long long mod=1e9+;
int main()
{
q.clear();
cin>>n;
for(int i=;i<=n;i++)
{
long long num;
cin>>num;
q[num]++;
}
if(q[]>)
{
cout<<""<<endl;
}
else if(q[]==||q[]==)
{
int num=;
for(it=q.begin();it!=q.end();it++)
{
if(it->second==)
{
num++;
}
else if(it->second>)
{
cout<<""<<endl;
return ;
}
}
num%=mod;
cout<<modl(,num,mod)%mod<<endl;
}
return ;
}

AtCoder Beginner Contest 050 ABC题的更多相关文章

  1. AtCoder Beginner Contest 068 ABCD题

    A - ABCxxx Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement This contes ...

  2. AtCoder Beginner Contest 053 ABCD题

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

  3. AtCoder Beginner Contest 069 ABCD题

    题目链接:http://abc069.contest.atcoder.jp/assignments A - K-City Time limit : 2sec / Memory limit : 256M ...

  4. AtCoder Beginner Contest 088 (ABC)

    A - Infinite Coins 题目链接:https://abc088.contest.atcoder.jp/tasks/abc088_a Time limit : 2sec / Memory ...

  5. AtCoder Beginner Contest 087 (ABC)

    A - Buying Sweets 题目链接:https://abc087.contest.atcoder.jp/tasks/abc087_a Time limit : 2sec / Memory l ...

  6. AtCoder Beginner Contest 070 ABCD题

    题目链接:http://abc070.contest.atcoder.jp/assignments A - Palindromic Number Time limit : 2sec / Memory ...

  7. AtCoder Beginner Contest 057 ABCD题

    A - Remaining Time Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Dol ...

  8. AtCoder Beginner Contest 051 ABCD题

    A - Haiku Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement As a New Yea ...

  9. AtCoder Beginner Contest 058 ABCD题

    A - ι⊥l Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Three poles st ...

随机推荐

  1. springMVC+spring+hibernate注解上传文件到数据库,下载,多文件上传

    数据库 CREATE TABLE `annex` ( `id` bigint() NOT NULL AUTO_INCREMENT, `realName` varchar() DEFAULT NULL, ...

  2. c++ basic 整理2

    ​//拷贝函数 //拷贝构造函数是一种特殊的构造函数,函数的名称必须和类名称一致,它必须的一个参数是本类型的一个引用变量. //不显式指定拷贝函数时,编译器会生成默认拷贝函数. //使用默认拷贝函数 ...

  3. BizTalk动手实验(十五)AS2消息安全传输

    1 课程简介 本课程将配置AS2相关的安全传输配置,学员可以通过本课程熟悉相关的安全配置. 2 准备工作 为了模拟实际的B2B交互过程,本实验需要2台BizTalk Server 2010虚拟机(两两 ...

  4. python子类调用父类的方法

    python子类调用父类的方法 python和其他面向对象语言类似,每个类可以拥有一个或者多个父类,它们从父类那里继承了属性和方法.如果一个方法在子类的实例中被调用,或者一个属性在子类的实例中被访问, ...

  5. poj2142-The Balance(扩展欧几里德算法)

    一,题意: 有两个类型的砝码,质量分别为a,b;现在要求称出质量为d的物品, 要用多少a砝码(x)和多少b砝码(y),使得(x+y)最小.(注意:砝码位置有左右之分). 二,思路: 1,砝码有左右位置 ...

  6. Git: untrack a file in local repo only and keep it in the remote repo

    You could update your index: git update-index --assume-unchanged nbproject/project.properties and ma ...

  7. 土壤湿度传感器YL69使用

    1.电源:3.3V ~ 5V 2.获取湿度信息的方式(2种可同时使用): 从传感器的D0引脚:土壤湿度大于某个阈值,则D0输出0,否则输出1 从传感器的A0引脚:获取到模拟量,更加精确.土壤湿度越大, ...

  8. 8 ways rich people view the world differently than the average person

    Self-made millionaire Steve Siebold spent 26 years interviewing some of the wealthiest people in the ...

  9. 学习mysql

    一 概述 1.什么是数据库 数据库就是数据的仓库. mysql是对数据库进行存储和指令操作的软件.这类软件成为数据管理系统Database Management System. 2.mysql的安装和 ...

  10. [LeetCode]题解(python):119 Pascal's Triangle II

    题目来源 https://leetcode.com/problems/pascals-triangle-ii/ Given an index k, return the kth row of the ...