版本4和5间的区别
于2006-03-11 16:15:38修订的的版本4
大小: 1515
编辑: czk
备注:
于2006-04-16 18:17:32修订的的版本5
大小: 2173
编辑: czk
备注:
删除的内容标记成这样。 加入的内容标记成这样。
行号 2: 行号 2:

http://acm.zju.edu.cn/show_problem.php?pid=2329
行号 63: 行号 65:
http://acm.zju.edu.cn/show_problem.php?pid=2329
行号 65: 行号 67:

{{{#!cplusplus
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main() {
 string a;
 int caseno = 0;
 while( cin >> a ) {
  size_t total_a = std::count(a.begin(), a.end(), 'a');
  size_t total_b = std::count(a.begin(), a.end(), 'b');
  if(total_a > total_b) swap(total_a, total_b);
  cout <<"AB Circle #"<< ++caseno <<":"<<'\n';
  for(size_t i = 0; i < total_a + total_b -1; i++) {
   if(total_a <= total_b && i < total_b)
    cout << i <<',' << i+total_a << '\n';
   if(total_a != total_b && i < total_a )
    cout << i <<',' << i+total_b << '\n' ;
  }
  cout << '\n';
 }
 return 0;
}
}}}

AB Circle

http://acm.zju.edu.cn/show_problem.php?pid=2329

Time limit: 1 Seconds

Memory limit: 32768K

A circle formed by 'a' and 'b', you are required to figure out all such pairs of positions that when cutting the circle in a pair of the positions, we will get two segments that the number of 'a's in one segment is equal to the number of 'b's in the other segment.

attachment:abcircle.gif

1. Input

The length of circle: n is between 2 and 1000 inclusive.

All the characters in the input is either 'a' or 'b'.

There is no strings without any 'a' in the input.

There is no strings without any 'b' in the input.

2. Output

There are no more than 400 test cases. For each test case, print out all the correct cuttings. For each cutting, print out a pair of integers, representing the two positions to cut on.

In output, all the pairs of positions should be sorted.

The legal positions' number is between 0 and n-1 inclusive.

Print a blank line after each test case.

3. Sample Input

zju2329 (2008-02-23 15:36:39由localhost编辑)

ch3n2k.com | Copyright (c) 2004-2020 czk.