Measuring Lengths in Baden

进制转换 水题

#include<bits/stdc++.h>
using namespace std; int main()
{
int n;
scanf("%d",&n);
int a=n/36;
n-=a*36;
int b=(n)/3;
if((n%3)>=2)b++;
while(b>=12)b-=12,a+=1;
printf("%d %d\n",a,b);
return 0;
}

Simple XML

用栈实现的括号匹配相信大家都会

当然所有栈都可以用更直接粗暴的方法实现。

#include <iostream>

using namespace std;

int main()
{
string s; int x=0,y=0;
cin >> s;
for(int i=0; s[i]; i++)if(s[i]=='>')
{
if(s[i-2]=='/')y-=2;
for(int i=0; i<y; i++)cout<<" ";
for(int j=x; j<=i; j++)cout<<s[j]; cout<<endl;
if(s[i-2]!='/')y+=2;x=i+1;
}
}

Hobbits' Party

很简单的贪心构造

#include<bits/stdc++.h>
using namespace std; const int N=500;
vector<int> gues[N];
int main()
{
gues[1].resize(2);gues[2].resize(2);gues[3].resize(2);
gues[1][0]=1;gues[1][1]=2;
gues[2][0]=1;gues[2][1]=3;
gues[3][0]=2;gues[3][1]=3;
int k;
scanf("%d",&k);
k-=3;
int t=3;
int i;
for( i=4;;i++)
{
if((i-1)>k)break;
for(int j=1;j<=i-1;j++)
{
gues[j].push_back((t+j));
gues[i].push_back((t+j));
}
t+=(i-1);
k-=(i-1);
}
printf("%d\n",i-1);
for(int j=1;j<i;j++)
{ for(int k=0;k<gues[j].size();k++)
printf("%d ",gues[j][k]);
printf("\n");
}
return 0;
}

  

Two progressions

给定一个序列 试问能否将它拆分成两个等差数列 满足元素之间的相对位置不改变

暴力分配每个元素属于第一个还是第二个序列即可

剪枝:每个元素对于每个公差的序列只用搜索一次(证明方法自己思考)

#include<cstdio>
#include<set>
using namespace std; int n, al, bl, ff, i;
int s[30000], a[30000], b[30000];
set<int> visa[30000], visb[30000]; void dfs(){
if(al == n) return;
if(al + bl == n) {ff = 1; return;}
if(al < 2 || s[al+bl]-a[al-1] == a[al-1]-a[al-2] && (visb[al+bl].find(a[al-1]-a[al-2])==visb[al+bl].end())){
a[al] = s[al+bl];
if(al>1) visa[al+bl].insert(a[al]-a[al-1]);
al++;
dfs();
if(ff) return;
al--;
}
if(bl < 2 || s[al+bl]-b[bl-1] == b[bl-1]-b[bl-2] && (visa[al+bl].find(b[bl-1]-b[bl-2])==visa[al+bl].end())){
b[bl] = s[al+bl];
if(bl>1) visb[al+bl].insert(b[bl]-b[bl-1]);
bl++;
dfs();
if(ff) return;
bl--;
}
} int main(){
scanf("%d", &n);
for(i = 0; i < n; i++)
scanf("%d", &s[i]);
ff = al = bl = 0;
dfs();
if(ff){
for(i = 0; i < al; i++)
printf("%d ", a[i]);
printf("\n");
for(i = 0; i < bl; i++)
printf("%d ", b[i]);
printf("\n");
}
else
printf("No solution\n");
return 0;
}

  

MST Company

传送门

codeforces 125 A-E 补题的更多相关文章

  1. You Are Given a Decimal String... CodeForces - 1202B [简单dp][补题]

    补一下codeforces前天教育场的题.当时只A了一道题. 大致题意: 定义一个x - y - counter :是一个加法计数器.初始值为0,之后可以任意选择+x或者+y而我们由每次累加结果的最后 ...

  2. codeforces round 422 div2 补题 CF 822 A-F

    A I'm bored with life 水题 #include<bits/stdc++.h> using namespace std; typedef long long int LL ...

  3. codeforces round 421 div2 补题 CF 820 A-E

    A Mister B and Book Reading  O(n)暴力即可 #include<bits/stdc++.h> using namespace std; typedef lon ...

  4. Codeforces round 419 div2 补题 CF 816 A-E

    A Karen and Morning 水题 注意进位即可 #include<bits/stdc++.h> using namespace std; typedef long long i ...

  5. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  6. codeforces 447 A-E div2 补题

    A DZY Loves Hash 水题 #include<iostream> #include<cstdio> #include<cstdlib> #include ...

  7. codeforces round 418 div2 补题 CF 814 A-E

    A An abandoned sentiment from past 水题 #include<bits/stdc++.h> using namespace std; int a[300], ...

  8. codeforces round 417 div2 补题 CF 812 A-E

    A Sagheer and Crossroads 水题略过(然而被Hack了 以后要更加谨慎) #include<bits/stdc++.h> using namespace std; i ...

  9. Codeforces Beta Round #1 补题题解

    A Theatre Square(数学) 算出每行能装多少乘以每列能装多少就行 公式 ans=ceil(n/a)+ceil(m/a) 代码 #include <bits/stdc++.h> ...

  10. codeforces round 416 div2 补题 CF 811 A B C D E

    A. Vladik and Courtesy 水题略过 #include<cstdio> #include<cstdlib> #include<cmath> usi ...

随机推荐

  1. 《Docker容器与容器云》读书笔记

    云计算平台 云计算是一种资源的服务模式,该模式可以实现随时随地.便捷按需地从可配置计算资源共享池中获取所需资源(如网络.服务器.存储.应用及服务),资源能够快速供应并释放,大大减少了资源管理工作开销. ...

  2. [HDU2157]How many ways??(DP + 矩阵优化)

    传送门 k < 20 k这么小,随便dp一下就好了... dp[i][j][k]表示从i到j经过k个点的方案数 4重循环.. 但是如果k很大就不好弄了 把给定的图转为邻接矩阵,即A(i,j)=1 ...

  3. [转]fedora国内源常见配置

    1.参考:1.http://mirrors.ustc.edu.cn/2.http://mirrors.fedoraproject.org/publiclist#CN3.http://mirrors.n ...

  4. Codeforces Round #294 (Div. 2) D. A and B and Interesting Substrings [dp 前缀和 ]

    传送门 D. A and B and Interesting Substrings time limit per test 2 seconds memory limit per test 256 me ...

  5. 【微信小程序】开发实战 之 「开发框架MINA构成」

    小程序开发框架的目标是通过尽可能简单.高效的方式让开发者可以在微信中开发具有原生 APP 体验的服务. 微信团队为小程序提供的框架命名为MINA.MINA框架通过封装微信客户端提供的文件系统.网络通信 ...

  6. Linux查看日志三种命令(转载)

    第一种:查看实时变化的日志(比较吃内存) 最常用的: tail -f filename (默认最后10行,相当于增加参数 -n 10) Ctrl+c 是退出tail命令 其他情况: tail -n 2 ...

  7. CPU 天梯图

  8. [vxlan] 一 Why VXLAN

    想了解一个事物/概念,最好的办法是知道它是为什么出现的,为了解决那些问题而出现.这里,就用这种方式来学习一下VXLAN VXLAN (Virtual eXtensible Local Area Net ...

  9. sendEmail实现邮件报警发送

    安装wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz tar -xf sendEmail-v ...

  10. 电脑控制手机的另一选择——android vnc server

    近来发现的Android上的原生VNC Server,就是说只要手机上安装并运行这个软件,即可实现电脑上查看并控制手机了. 首先是手机端. 1)下载androidvncserver: http://c ...