跳过正文
  1. Posts/

codeforces 612 A. The Text Splitting

http://codeforces.com/contest/612/problem/A 水题…直接枚举就好。

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2015年12月25日 星期五 22时58分26秒
 4File Name :code/cf/edu4/A.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33const int N=105;
34int n,p,q;
35char st[N];
36bool v[10005];
37int main()
38{
39	#ifndef  ONLINE_JUDGE
40	freopen("code/in.txt","r",stdin);
41  #endif
42	cin>>n>>p>>q;
43	cin>>st;
44	ms(v,false);
45	int b,c;
46	for ( int i = 0 ; i*p<=105 ; i++ )
47	{
48	    for ( int j = 0 ; j*q <= 105 ; j++)
49	    {
50		v[i*p+j*q] = true;
51		if (i*p+j*q==n)
52		{
53		    b = i;
54		    c = j;
55		}
56	    }
57	}
58//	cout<<"b:"<<b<<endl;
59//	cout<<"c:"<<c<<endl;
60	if (!v[n])
61	{
62	    puts("-1");
63	}
64	else
65	{
66	    int cnt = 0 ;
67	    printf("%d\n",b+c);
68	    for ( int i = 1 ; i <=  b ; i++)
69	    {
70		for ( int i = 0 ; i < p ; i++)
71		    printf("%c",st[cnt]),cnt++;
72		printf("\n");
73	    }
74	    for ( int i =1 ; i <= c ; i++)
75	    {
76		for ( int i = 0 ; i < q ; i++)
77		    printf("%c",st[cnt]),cnt++;
78		printf("\n");
79	    }
80	}
81
82
83
84  #ifndef ONLINE_JUDGE
85  fclose(stdin);
86  #endif
87    return 0;
88}

相关文章

codeforces #336 div 2 A. Saitama Destroys Hotel

·1 分钟
http://codeforces.com/contest/608/problem/A 题意:一个电梯,从s到0层,单项,给出n个人,每个人在某时间出现在某层,问要花多长时间把所有人运到0。初始电梯在s,每下一层话费时间1,上来人不花时间。 思路:由于电梯只能是单项,那么到达某一层的时候,一定要等到把这层中最晚来的那个接走。所以排序的时候按照楼层高到低为第一关键字,等待时间长到短为第二关键字。对于同一楼层出现的,只考虑第一个即可,也就是最后出现的。需要注意的是最后接完最后一个人以后把电梯运行道0层。

codeforces 466 C. Number of Ways

·2 分钟
http://codeforces.com/problemset/problem/466/C 题意:给定一个序列。要将序列分成三个非零的连续部分,使得三部分的和相等。问有多少中分法。 思路:首先可以知道,如果是序列的和不为3的倍数,那么一定无解,输出0.设序列的和为sum,那么每一部分的和就应该为sum/3。我们可以预处理出从1开始的和为sum/3的点(我开了数组表示前缀和。。想了下其实不用。。我只需要点的信息。。所以用一个变量表示即可),将点的下标存在p[i]里。对于每一个p[i],我想要知道比p[i]大且补与p[i]相邻的点中,有多少个j,使得从j到n的和为sum/3。因为如果有两部分的和都为sum/3,那么剩下的那部分也一定为sum/3.然后要知道有多少个满足题意的j,我们可以从后往前扫一遍,标记从n开始往前扫,和为sum/3的点,可以用一个0,1数组表示。如果和为sum/3,那么标记为1,否则为0.然后再用一个类似前缀和的思路。再开一个数组c记录从j到n有的和为多少,也就是从j到n有多少个点满足该点到n的和为sum/3.

codeforces 522 A. Vanya and Table

http://codeforces.com/problemset/problem/552/A 题意:一个100*100的网格。然后给n个矩形。每个格子中填上包含这个格子的矩形的个数。最后问所有格子的和。 思路:树状数组搞得…然而..直接求所有矩形面积的和就可以啊喂。。o(n)。。。111qqz你个炒鸡大菜鸡。