A - Two Rectangles


Time limit : 2sec / Memory limit : 256MB

Score : 100 points

Problem Statement

There are two rectangles. The lengths of the vertical sides of the first rectangle are A, and the lengths of the horizontal sides of the first rectangle are B. The lengths of the vertical sides of the second rectangle are C, and the lengths of the horizontal sides of the second rectangle are D.

Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.

Constraintsfewfew

  • All input values are integers.
  • 1≤A≤104
  • 1≤B≤104
  • 1≤C≤104
  • 1≤D≤104

Input

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

A B C D

Output

Print the area of the rectangle with the larger area. If the two rectangles have equal areas, print that area.


Sample Input 1

Copy
3 5 2 7

Sample Output 1

Copy
15

The first rectangle has an area of 3×5=15, and the second rectangle has an area of 2×7=14. Thus, the output should be 15, the larger area.


Sample Input 2

Copy
100 600 200 300

Sample Output 2

Copy
60000
题意:求哪个的面积最大
解法:比较大小
 1 #include<bits/stdc++.h>
2 using namespace std;
3 #define ll long long
4 int main()
5 {
6 ll a,b,c,d;
7 cin>>a>>b>>c>>d;
8 cout<<max(a*b,c*d);
9 return 0;
10 }

B - Increment Decrement


Time limit : 2sec / Memory limit : 256MB

Score : 200 points

Problem Statement

You have an integer variable x. Initially, x=0.

Some person gave you a string S of length N, and using the string you performed the following operation N times. In the i-th operation, you incremented the value of x by 1 if Si=I, and decremented the value of x by 1 if Si=D.

Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).

Constraints

  • 1≤N≤100
  • |S|=N
  • No characters except I and D occur in S.

Input

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

N
S

Output

Print the maximum value taken by x during the operations.


Sample Input 1

Copy
5
IIDID

Sample Output 1

Copy
2

After each operation, the value of x becomes 1221 and 2, respectively. Thus, the output should be 2, the maximum value.


Sample Input 2

Copy
7
DDIDDII

Sample Output 2

Copy
0

The initial value x=0 is the maximum value taken by x, thus the output should be 0.

题意:I是增长,D是下降,现在求变化中的最大值

解法:模拟

 1 #include<bits/stdc++.h>
2 using namespace std;
3 #define ll long long
4 int main()
5 {
6 ll a,b,c,d;
7 cin>>a;
8 string s;
9 cin>>s;
10 ll sum=0;
11 ll max1=0;
12 for(int i=0;i<a;i++)
13 {
14 if(s[i]=='I')
15 {
16 sum++;
17 }
18 else
19 {
20 sum--;
21 }
22 max1=max(sum,max1);
23 }
24 cout<<max1<<endl;
25 return 0;
26 }

C - Factors of Factorial


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

You are given an integer N. Find the number of the positive divisors of N!, modulo 109+7.

Constraints

  • 1≤N≤103

Input

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

N

Output

Print the number of the positive divisors of N!, modulo 109+7.


Sample Input 1

Copy
3

Sample Output 1

Copy
4

There are four divisors of 3! =6123 and 6. Thus, the output should be 4.


Sample Input 2

Copy
6

Sample Output 2

Copy
30

Sample Input 3

Copy
1000

Sample Output 3

Copy
972926972

题意:求N!能被多少个数整除

解法: 额。。。http://oeis.org/A027423

 #include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef long long LL;
LL fun(LL x,LL n)
{
LL res=;
while(n>)
{
if(n & )
res=(res*x);
x=(x*x);
n >>= ;
}
return res;
}
ll a[]={, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,};
int main()
{
ll n;
ll mod=1e9+;
ll ans=;
cin>>n;
ll b[];
int pos=;
while()
{
if(a[pos]<=n)
{
pos++;
}
else
{
break;
}
}
//cout<<<<endl;
for(int i=; i<=pos-; i++)
{
ll sum=;
for(int j=; j<=n; j++)
{
if(fun(a[i],j)<=n)
{
sum+=(n/fun(a[i],j));
}
else
{
break;
}
}
ans=ans*(sum+);
ans%=mod;
}
cout<<ans<<endl;
return ;
}

D - Walk and Teleport


Time limit : 2sec / Memory limit : 256MB

Score : 500 points

Problem Statement

There are N towns on a line running east-west. The towns are numbered 1 through N, in order from west to east. Each point on the line has a one-dimensional coordinate, and a point that is farther east has a greater coordinate value. The coordinate of town i is Xi.

You are now at town 1, and you want to visit all the other towns. You have two ways to travel:

  • Walk on the line. Your fatigue level increases by A each time you travel a distance of 1, regardless of direction.

  • Teleport to any location of your choice. Your fatigue level increases by B, regardless of the distance covered.

Find the minimum possible total increase of your fatigue level when you visit all the towns in these two ways.

Constraints

  • All input values are integers.
  • 2≤N≤105
  • 1≤Xi≤109
  • For all i(1≤iN−1)Xi<Xi+1.
  • 1≤A≤109
  • 1≤B≤109

Input

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

N A B
X1 X2 XN

Output

Print the minimum possible total increase of your fatigue level when you visit all the towns.


Sample Input 1

Copy
4 2 5
1 2 5 7

Sample Output 1

Copy
11

From town 1, walk a distance of 1 to town 2, then teleport to town 3, then walk a distance of 2 to town 4. The total increase of your fatigue level in this case is 2×1+5+2×2=11, which is the minimum possible value.


Sample Input 2

Copy
7 1 100
40 43 45 105 108 115 124

Sample Output 2

Copy
84

From town 1, walk all the way to town 7. The total increase of your fatigue level in this case is 84, which is the minimum possible value.


Sample Input 3

Copy
7 1 2
24 35 40 68 72 99 103

Sample Output 3

Copy
12

Visit all the towns in any order by teleporting six times. The total increase of your fatigue level in this case is 12, which is the minimum possible value.

题意:看样列知题意

解法:每一步都取最小值

#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef long long LL;
LL fun(LL x,LL n)
{
LL res=;
while(n>)
{
if(n & )
res=(res*x);
x=(x*x);
n >>= ;
}
return res;
}
ll a[]={, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,};
int main()
{
ll dp[];
ll a[];
ll n,x,b;
cin>>n>>x>>b;
for(int i=;i<=n;i++)
{
cin>>a[i];
}
dp[]=;
a[]=;
for(int i=;i<=n;i++)
{
dp[i]=min(dp[i-]+(a[i]-a[i-])*x,dp[i-]+b);
}
cout<<dp[n]<<endl;
return ;
}

AtCoder Beginner Contest 052 ABCD题的更多相关文章

  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 070 ABCD题

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

  5. AtCoder Beginner Contest 057 ABCD题

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

  6. AtCoder Beginner Contest 051 ABCD题

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

  7. AtCoder Beginner Contest 054 ABCD题

    A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...

  8. AtCoder Beginner Contest 058 ABCD题

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

  9. AtCoder Beginner Contest 052

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

随机推荐

  1. 双重检查锁定与延迟初始化(转自infoq)

    很好的文章,转自http://www.infoq.com/cn/articles/double-checked-locking-with-delay-initialization 在java程序中,有 ...

  2. 上传Android或Java库到Maven central repository(转载)

    主要介绍利用Sonatype将jar或aar提交到Maven的中央仓库. 是不是希望将自己的jar或是aar传到maven官方库中,在The Central Repository中可以被其他人搜索使用 ...

  3. c++ data语意学

     Data Member的绑定 extern float x; class Point3d { public: point3d(); //问题:被传回和被设定的x是哪一个x呢? float X() c ...

  4. 阅读 LdrInitializeThunk

    参考: http://blog.csdn.net/hw_henry2008/article/details/6568255 Windows 的 DLL 装入(除 ntdll.dll 外)和连接是通过 ...

  5. ListView使用的时候遇到的一些问题

    昨天在做项目时,请求服务器的好友动态后,将好友动态和评论显示到界面上,用ListView显示,发现一进这个界面时,listView的适配器的getVIew()方法就会执行6次,后来发现原来是ListV ...

  6. 创建 AngularJS 自定义过滤器,带自定义参数

    Angularjs过滤器是 angularjs非常棒的特性之一.有朝一日,你可能需要使用自定义过滤器,幸运的是,你找到了这篇博文. 下面显示的是自定义过滤器长什么样子(请注意myfilter): &l ...

  7. 转 如何高效使用和管理Bitmap--图片缓存管理模块的设计与实现

    上周为360全景项目引入了图片缓存模块.因为是在Android4.0平台以上运作,出于惯性,都会在设计之前查阅相关资料,尽量避免拿一些以前2.3平台积累的经验来进行类比处理.开发文档中有一个 Bitm ...

  8. 转 区别 getChildFragmentManager getSupportFragmentManager

    The definition of getChildFragmentManager() is: Return a private FragmentManager for placing and man ...

  9. gen_grant_sel.sql

    set echo off feedback off verify off pagesize 0 linesize 120 define v_grantee=&1 define v_grant_ ...

  10. POJ 3624 Charm Bracelet 简单01背包

    题目大意:有n件珠宝,每个珠宝的魅力值为v,重量为w,求在重量不超过m的情况下能达到的最大魅力值. 题目思路:简单的01背包,由于二维数组会超内存所以应该压缩成一维数组. dp[i][j],表示选取i ...