Fight For ACM

Kyrieh 发表于 2009-07-30 20:55:24

                     10.26  - 10.28                    南京赛区            

                      11.2   -  11.3                      日本赛区            

好久不来

Kyrieh 发表于 2009-07-25 15:50:50

            这里已经长草了。
            看到有人在这里骂脏话很不爽。
            代码有用就拿走。没有注释请自己读代码。
            如果RE了TLE了,请无视继续google。我相信大家都是搜索到了这个页面。
            曾经在这里贴代码的人已经远离ACM-ICPC很久了。
            请不要这样践踏别人的成果。

计算几何

Tsuzuki 发表于 2008-08-03 10:04:15

      由于被某题搞昏了,就在网上发现了这么个东西。有一些基本的计算几何判断


             http://blog.csdn.net/lithe/archive/2005/01/22/263487.aspx

PKU3105 Expectation

Tsuzuki 发表于 2008-07-10 17:22:55

    即将有新的组织。心情颇为复杂。希望新的member加油。。

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main()
{
  int tot , n;
  double save , ans;
  long long M , MM , p0 , p1 , tmp , nn , temp;

  scanf("%d" , &tot);
  while (tot--)
    {
      scanf("%d" , &n);
      M = 1;
      tmp = n - 1;
      nn = n - 1;
      save = n;
      save *= n;
      ans = 0;
      for ( ; tmp ; tmp /= 2 , M *= 2)
 {
   MM = M * 2;
   temp = nn / MM + 1;
   if (tmp % 2)
     {
       p0 =  temp * M;
       p1 =  (temp - 1) * M + nn % M + 1;
     }
   else {
     p0 = (temp - 1) * M + nn % M + 1;
     p1 = (temp - 1) * M;
   }
   double tt = p0;
   tt *= p1 , tt *= MM;
   ans += tt / save;
 }

      printf("%.2lf\n" , ans);
    }
}

PKU3535 A+B

Tsuzuki 发表于 2008-04-20 13:19:24

      其实我真的写不动代码啊~~~感觉点积差积都不记得了~~~怎么办啊。。。。。TAT

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

const int maxN = 100005;
const int N = 26;

char s[maxN];
int exist[maxN][30] , cnt[maxN] , a[4][maxN] , b[maxN];
int n , m;

void init()
{
  scanf("%d %d" , &m , &n);
  for (int i = 0 ; i < n ; ++i)
    {
      scanf("%s" , s);
      for (int j = 0 ; j < m ; ++j)
 exist[j][s[j] - 'a'] = 1;
    }

  memset(cnt , 0 , sizeof(cnt));
  for (int i = 0 ; i < m ; ++i)
    for (int j = 0 ; j < N ; ++j)
      if (!exist[i][j])
      exist[i][j] = cnt[i]++;
      else exist[i][j] = -1;

  for (int j = 0 ; j < 2 ; ++j)
    {
      scanf("%s" , s);
      for (int i = 0 ; i < m ; ++i)
 a[j][i] = exist[i][s[i] - 'a'];
    }
}

void work()
{
  int w = 0;

  for (int i = 0 ; i < m ; ++i)
    a[2][i] = a[0][i] + a[1][i];
  for (int i = m - 1 ; i >= 0 ; --i)
    {
      a[2][i] += w;
      w = a[2][i] / cnt[i];
      a[2][i] %= cnt[i];
    }
}

void show()
{
  for (int i = 0 ; i < m ; ++i)
    for (int j = 0 ; j < N ; ++j)
      if (exist[i][j] == a[2][i])
 printf("%c" , j + 'a');
  printf("\n");
}

int main()
{
  init();
  work();
  show();
}

 

PKU3510 A Tale from the Dark Side of the Moon

Tsuzuki 发表于 2008-03-18 21:17:43

     我想说这题目好无聊.....-____-||||

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

char s[1000];
int L;
bool END;

void translate()
{
  L = strlen(s);
  for (int i = 0 ; i < L ; ++i)
    if (s[i] == ' ') printf(" ");
    else if (i + 2 < L && s[i] == 'E' && s[i + 1] == 'O' && s[i + 2] == 'F')
      {
 END = 1;
 if (i) printf("\n");
 return;
      }
    else if (s[i] >= 'a' && s[i] <= 'z')
      if (i < L - 1 && s[i] == 'd' && s[i + 1] == 'd')
 {
   printf("p");++i;
 }
      else if (i < L - 1 && s[i] == 'e' && s[i + 1] == 'i' && (!i || s[i - 1] != 'c'))
 {
   printf("ie");++i;
 }
      else if (i + 3 < L && s[i] == 'p' && s[i + 1] == 'i' && s[i + 2] == 'n' && s[i + 3] == 'k')
 {
   printf("floyd");i += 3;
 }
      else printf("%c" , s[i]);
  printf("\n");
}

int main()
{
  END = 0;
  while (!END && gets(s))
      translate();
}