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. CGFloat和float

    CGFloat :在mac上自适应,在64位的系统,会变宽,32位会变窄,手机没变化float:没有变化

  2. Codeforces Round #277(Div 2) A、B、C、D、E题解

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud A. Calculating Function 水题,判个奇偶即可 #includ ...

  3. (原)使用opencv的warpAffine函数对图像进行旋转

    转载请注明出处: http://www.cnblogs.com/darkknightzh/p/5070576.html 参考网址: http://stackoverflow.com/questions ...

  4. maven配置spring mvc+hibernate+spring框架

    作为一名刚出茅草屋的新手小白写的框架,仅适合新手小白借鉴,大神勿喷,谢谢...... 前天刚知道spring mvc这个框架现在也很流行,决定用它代替struts2来写我的毕业设计. ...作为一名新 ...

  5. android 开发环境搭建 (转)

    最近由于工作中要负责开发一款Android的App,之前都是做JavaWeb的开发,Android开发虽然有所了解,但是一直没有搭建开发环 境去学习,Android的更新速度比较快了,Android1 ...

  6. R语言学习笔记(数据的读取与保存)

    library(MASS)#载入package MASSdata(package="MASS") #查看MASS中的数据集data(SP500,package="MASS ...

  7. PHP API反射实例

    *反射是操纵面向对象范型中元模型的API,其功能十分强大,可帮助我们构建复杂,可扩展的应用.其用途如:自动加载插件,自动生成文档,甚至可用来扩充PHP语言.php反射api由若干类组成,可帮助我们用来 ...

  8. werkzeug源码阅读笔记(二) 上

    因为第一部分是关于初始化的部分的,我就没有发布出来~ wsgi.py----第一部分 在分析这个模块之前, 需要了解一下WSGI, 大致了解了之后再继续~ get_current_url()函数 很明 ...

  9. 蘑菇街2015校招技术类笔试题A卷,回忆版(杭州站)

    笔试时间:10月9号 下午 1.一串数据的最大递增序列,输出个数 例如 4,2, 6,3, 1,5, 最大递增序列为, 2,3, 5,输出3, 2.求两个整型数据集合的交集,尽可能少用时间. 假设两个 ...

  10. Keil C51汉字显示的bug问题(0xFD问题)

    一.缘起 这两天改进MCU的液晶显示方法,采用“即编即显”的思路,编写了一个可以直接显示字符串的程序.如程序调用disstr("我是你老爸");液晶屏上就会显示“我是你老爸”. 二 ...