1001

求个绝对值比较大小喽

1002

把字符串出现的字母记录一下,然后遍历a-z,谁第一个没出现就输出谁

1003

Problem Statement

We have N sticks with negligible thickness. The length of the i-th stick is Ai.

Snuke wants to select four different sticks from these sticks and form a rectangle (including a square), using the sticks as its sides. Find the maximum possible area of the rectangle.

Constraints

  • 4≤N≤105
  • 1≤Ai≤109
  • Ai is an integer.

Input

Input is given from Standard Input in the following format:

N
A1 A2 ... AN

Output

Print the maximum possible area of the rectangle. If no rectangle can be formed, print 0.

题意:选出四个点能组成矩形,且面积最大

解法:选4个一样的点或者是选两个出现两次以上的最大数字

 #include<bits/stdc++.h>
using namespace std;
map<int,int>Mp,mp,ap;
int n;
long long A[];
int ans;
int main(){
long long x=,y=;
int flag1=,flag2=;
scanf("%d",&n);
for(int i=;i<=n;i++){
cin>>A[i];
Mp[A[i]]++;
}
sort(A+,A++n);
for(int i=n;i>=;i--){
if(Mp[A[i]]>=&&mp[A[i]]==){
mp[A[i]]=;
x*=A[i];
ans++;
}
if(ans==){
flag1=;
break;
}
}
for(int i=n;i>=;i--){
if(Mp[A[i]]>=){
y*=(A[i]*A[i]);
flag2=;
break;
}
}
if(flag1||flag2){
cout<<max(x,y)<<endl;
}else{
cout<<""<<endl;
}
return ;
}

Problem Statement

We have a board with a N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1×2 or 2×1 square.

Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side should be painted by different colors. Here, it is not always necessary to use all three colors.

Find the number of such ways to paint the dominoes, modulo 1000000007.

The arrangement of the dominoes is given to you as two strings S1 and S2 in the following manner:

  • Each domino is represented by a different English letter (lowercase or uppercase).
  • The j-th character in Si represents the domino that occupies the square at the i-th row from the top and j-th column from the left.

Constraints

  • 1≤N≤52
  • |S1|=|S2|=N
  • S1 and S2 consist of lowercase and uppercase English letters.
  • S1 and S2 represent a valid arrangement of dominoes.

Input

Input is given from Standard Input in the following format:

N
S1
S2

Output

Print the number of such ways to paint the dominoes, modulo 1000000007.


Sample Input 1

Copy
3
aab
ccb

Sample Output 1

Copy
6

There are six ways as shown below:


Sample Input 2

Copy
1
Z
Z

Sample Output 2

Copy
3

Note that it is not always necessary to use all the colors.


Sample Input 3

Copy
52
RvvttdWIyyPPQFFZZssffEEkkaSSDKqcibbeYrhAljCCGGJppHHn
RLLwwdWIxxNNQUUXXVVMMooBBaggDKqcimmeYrhAljOOTTJuuzzn

Sample Output 3

Copy
958681902
解法:把上面的图染色,且相邻的颜色不同
解法:
1. 原来没有
aa
aa这种情况,就说嘛,想了好久
2.
第一次出现的是横还是竖
横 *6
竖 *3
出现横时,上一次出现的是
横 *3
竖 *2
出现竖时,上一次出现的是
横 *1
竖 *2
 #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <map>
#define int long long using namespace std; const int mod=; char str[][]; signed main()
{
int n;
scanf("%lld",&n);
for(int i=; i<; i++)
{
scanf("%s",str[i]);
}
bool flag=false;
int f=;
int t=;
for(int i=; i<n; i++)
{
if(str[][i]==str[][i+])
{
if(f==)
{
t*=;
t*=;
f=;
}
else
{
if(flag)
{
t*=;
t*=;
}
else
{
t*=;
}
}
flag=false;
i++;
}
else
{
if(str[][i]==str[][i])
{
if(f==)
{
t*=;
f=;
}
else
{
if(flag) t*=;
else t*=;
}
flag=true;
}
}
t%=mod;
}
cout<<t<<endl;
return ;
}

AtCoder Beginner Contest 071 ABCD的更多相关文章

  1. AtCoder Beginner Contest 053 ABCD题

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

  2. AtCoder Beginner Contest 068 ABCD题

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

  3. AtCoder Beginner Contest 070 ABCD题

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

  4. AtCoder Beginner Contest 069 ABCD题

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

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

    A - Two Rectangles Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement The ...

  8. AtCoder Beginner Contest 071 D - Coloring Dominoes

    Problem Statement We have a board with a 2×N grid. Snuke covered the board with N dominoes without o ...

  9. AtCoder Beginner Contest 054 ABCD题

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

随机推荐

  1. Mac系统存储-其他存储无故增大

    解决办法:打开Finder:安全倾倒废纸篓就会减少很大一部分存储.

  2. CC通信软件list

    bozokgh0stnanocoredarkcometponydarkcometadwindadzokaecomblacknixbluebananacorigaratdarkcometDRAThuig ...

  3. 集训Day6

    今天的图论题略多 但好像都是noip题 bzoj3624 有一个图,边是黑色或者白色,求一个生成树满足恰好有k条白边 贪心 我们把最小生成树上的白边叫做“富家子弟”,把不在树上的叫“贫下中农” 很明显 ...

  4. BZOJ - 4518: 征途(斜率优化,求N数划分为M区间的最小方差)

    注意初始化...等等补 #include<bits/stdc++.h> #define ll long long using namespace std; ; int q[maxn],he ...

  5. TCP头部格式详解,附Wireshark对TCP头部抓包分析

    TCP之所以能为数据通讯提供可靠的传输,主要在于TCP数据包头部功能非常多. 那么,我们先来看看TCP头部格式(RFC 793.1323定义了TCP头部): TCP头部格式中的内容解析如下:(文末还有 ...

  6. 使用unlist将日期型数据的列表转换为向量时,出现的异常

    在使用unlist函数,将日期型的列表,转换为向量时,不会得到期望的结果,如下: > dateLst <- list(Sys.Date()) > dateLst [[1]] [1] ...

  7. mvc 自定义 AuthorizeAttribute 验证逻辑

    public class AuthorizationFilterAttribute : AuthorizeAttribute { Dictionary<string, string> ro ...

  8. 浅谈HTML移动Web开发(转)

    一.响应式Web设计 PC端常用的两种布局方式就是固定布局和弹性布局,前者设置一个绝大多数电脑能征服显示的固定宽度居中显示,后者则采用百分百. 响应式布局意味着媒体查询,响应式web设计并非新的技术, ...

  9. (三)整合SSH测试项目

    整合struts 和 spring 预期:如果可以在action中能够正确调用service里面的方法执行并返回到一个页面中:那么我们认定struts和spring的整合是成功的. 编写JUnit测试 ...

  10. ural 1500 Pass Licenses (状态压缩+dfs)

    1500. Pass Licenses Time limit: 2.5 secondMemory limit: 64 MB A New Russian Kolyan believes that to ...