A.

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int a,b,c;
int ans1,ans2,ans3;
int main()
{
//freopen("input.txt","r",stdin);
cin>>a>>b>>c;
int ans1=2*(a+b);
int ans2=2*(a+c);
int ans3=2*(b+c);
int ans4=a+b+c;
int w=min(min(ans1,ans2),min(ans3,ans4));
cout<<w<<endl;
}

B.

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<string>
using namespace std;
int n,m;
int ans[100005];
int w[100005];
map<int,int> q;
map<int,int>::iterator it;
int flag=2;
int main()
{
// freopen("input.txt","r",stdin);
int t;
scanf("%d%d",&n,&m);
for(int i=0;i<n;i++)
{
scanf("%d",&t);
q.insert(pair<int,int>(t,i+1));
ans[t]++;
}
for(int i=0;i<m;i++)
{
scanf("%d",&t);
it=q.find(t);
if(it!=q.end()&&flag!=1)
{
w[i]=it -> second;
if(ans[it->first]>1)
flag=0;
}
else
flag=1;
}
if(flag==1)
printf("Impossible\n");
else if(flag==0)
printf("Ambiguity\n");
else
{
printf("Possible\n");
for(int i=0;i<m;i++)
printf("%d ",w[i]);
}
}

C.

贪心:前缀最大值不大于后缀最小值

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
int a[100005];
int ma[100005];
int mi[100005];
int main()
{
int n,ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
ma[0]=-1;
for(int i=1;i<=n;i++)
{
ma[i]=max(ma[i-1],a[i]);
}
mi[n+1]=1e9+5;
mi[n]=a[n];
for(int i=n-1;i>=1;i--)
{
mi[i]=min(mi[i+1],a[i]);
}
for(int i=1;i<=n;i++)
{
if(ma[i]<=mi[i+1])
ans++;
}
printf("%d\n",ans);
}

D.数学题

f(n,m)=∑k=(n−k+1)(m−k+1)

f(n,m)=(n*n/2+n/2)m+n*n+n−(n+2)(n+1)n/2+n(n+1)(2*n+1)/6

枚举n

#include<cstdio>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<iostream>
#include<cstring>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> p;
long long n;
long long ans,x,y;
vector<p>t; int main()
{
scanf("%I64d",&n);
int xx=6*pow(n,1.0/3.0);
// printf("%d\n",xx);
for(long long i=1;i<=xx;i++)
{
x=(i*i+i)/2;
y=n-i*i-i+(i+2)*(i+1)*i/2-(i+1)*i*(2*i+1)/6;
if(y>0&&y%x==0)
{
ans++;
long long dd=y/x;
if(dd>=i){
t.push_back(make_pair<LL,LL>(i,dd));
t.push_back(make_pair<LL,LL>(dd,i));
}
}
}
sort(t.begin(),t.end());
int len=unique(t.begin(),t.end())-t.begin();
printf("%d\n",len);
for(int i=0;i<len;i++)
{
printf("%I64d %I64d\n",t[i].first,t[i].second);
}
}

codeforces #332 div2的更多相关文章

  1. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  2. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  3. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  4. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  5. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  6. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  7. codeforces #332 div 2 D. Spongebob and Squares

    http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...

  8. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  9. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

随机推荐

  1. 写一个Windows上的守护进程(5)文件系统重定向

    写一个Windows上的守护进程(5)文件系统重定向 在Windows上经常操作文件或注册表的同学可能知道,有"文件系统/注册表重定向"这么一回事.大致来说就是32位程序在64位的 ...

  2. SET XACT_ABORT 的用法[转]

    SET XACT_ABORT指定当 Transact-SQL 语句产生运行时错误时,Microsoft® SQL Server™ 是否自动回滚当前事务. 语法 SET XACT_ABORT { ON ...

  3. web.xml中配置Spring中applicationContext.xml的方式

    2011-11-08 16:29 web.xml中配置Spring中applicationContext.xml的方式 使用web.xml方式加载Spring时,获取Spring applicatio ...

  4. 如何只克隆git仓库中的一个分支?

    git clone -b 例如: git clone -b 指定的分支名字

  5. [C++程序设计]基于对象的程序设计 基于对象的程序设计

    1. 面向对象分析(object oriented analysis,OOA)2. 面向对象设计(object oriented design,OOD)3. 面向对象编程(object oriente ...

  6. CentOS6下编译安装Python2.7.6方法

    关于在CentOS6下编译安装Python2.7.6的方法非常的多了,小编以前也介绍过相关的文章了,下面一聚教程小编再来为各位介绍一下吧,希望文章能帮助到各位.   CentOS下面Python在升级 ...

  7. 小希的迷宫(HDU 1272 并查集判断生成树)

    小希的迷宫 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  8. 百度首页top设置

    html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  9. 风雨哈佛路(Homeless to Harvard: The Liz Murray Story)-献给困境中的人

                                                     今天无意中看到一部很老的电影<风雨哈佛路>,一曲感人励志向上的美国影片,整个故事震撼人心. ...

  10. 【转】android是32-bit系统还是64-bit系统

    原文网址:http://www.cnblogs.com/pengwang/archive/2013/03/11/2954496.html 电脑CPU分32位和64位,这个我们都知道.用了这么长时间的a ...