kk赛标程
  • 板块题目总版
  • 楼主kkksc03吉祥物
  • 当前回复2
  • 已保存回复2
  • 发布时间2014/10/2 13:57
  • 上次更新2024/4/5 16:09:03
查看原帖
kk赛标程
1
kkksc03吉祥物楼主2014/10/2 13:57

在 @[url=/space/show?uid=3150]slzxxjd[/url] 放题解前,我先把他的标称放出来

密令 [codep]

const  
  mo=1000000007;  
var  
  t,n,i,j,k,d,w:longint;  
  s:string;  
  a:array[0..100]of longint;  
  v:array[0..100,0..2600]of boolean;  
  f:array[0..100,0..2600]of longint;  
begin  
  f[0,0]:=1;  
  for i:=0 to 99 do  
    for j:=0 to 26*i do  
      if f[i,j]>0 then  
        for k:=j to j+25 do  
          begin  
            f[i+1,k]:=f[i+1,k]+f[i,j];  
            if f[i+1,k]>=mo then dec(f[i+1,k],mo);  
          end;  
  readln(t);  
  for t:=1 to t do  
    begin  
      readln(s);  
      n:=length(s);  
      for i:=1 to n do a[i]:=ord(s[i])-ord('a');  
      d:=0;  
      for i:=1 to n do  
        d:=d+a[i];  
      writeln((f[n,d]-1+mo)mod mo);  
    end;  
end.  

[/codep]

内存杀手

[codec]

/* Croatian Open Competition in Informatics 2006/2007

Contest 1 - Task DEBUG

Programming language C++

*/

#include <algorithm>  
#include <cstdio>  
using namespace std;  
typedef long long llint;  
int n, m;  
char a[300][300+1];  
llint mask[302][302][4]; // pamti 64 bita od pozicije (r,s) u smjeru d  
const int dr[4] = { 1, 0, -1, 0 };  
const int dc[4] = { 0, 1, 0, -1 };  
// inicijalizira mask[r][c][d]  
void init() {  
   for( int r = n-1; r >= 0; --r ) {  
      for( int c = m-1; c >= 0; --c ) {  
         for( int d = 0; d < 2; ++d ) {  
            int rr = r+dr[d];  
            int cc = c+dc[d];  
            if( rr >= 0 && rr < n && cc >= 0 && cc < m )  
               mask[r][c][d] = mask[rr][cc][d]<<1;  
            else  
               mask[r][c][d] = 0;  
            mask[r][c][d] |= a[r][c]=='1';  
         }  
      }  
   }  
   for( int r = 0; r < n; ++r ) {  
      for( int c = 0; c < m; ++c ) {  
         for( int d = 2; d < 4; ++d ) {  
            int rr = r+dr[d];  
            int cc = c+dc[d];  
            if( rr >= 0 && rr < n && cc >= 0 && cc < m )  
               mask[r][c][d] = mask[rr][cc][d]<<1;  
            else  
               mask[r][c][d] = 0;  
            mask[r][c][d] |= a[r][c]=='1';  
         }  
      }  
   }  
}  
// provjerava je li okvir (r,c) (r+size,c+size) ok  
int check( int r, int c, int size ) {  
   if( r < 0 || r+size >= n ) return 0;  
   if( c < 0 || c+size >= m ) return 0;  
   for( int d = 0; d < 2; ++d ) {  
      int r1 = r, c1 = c;  
      int r2 = r+size, c2 = c+size;  
      for( int s = size+1; s > 0; s -= 64 ) {  
         llint x = mask[r1][c1][d];  
         llint y = mask[r2][c2][d+2];  
         if( s >= 64 ) {  
            if( x^y ) return 0;  
         } else {  
            if( (x^y) & ((1LL<<s)-1) ) return 0;  
         }  
         r1 += 64*dr[d]; c1 += 64*dc[d];  
         r2 -= 64*dr[d]; c2 -= 64*dc[d];  
      }  
   }  
   return 1;  
}  
int main( void ) {  
   scanf( "%d%d", &n, &m );  
   for( int r = 0; r < n; ++r ) scanf( "%s", a[r] );  
   init();  
   int ret = 0;  
   for( int r = 0; r < n; ++r ) {  
      for( int c = 0; c < m; ++c )  
         for( int x = 0; x < 2; ++x ) {  
            int max_odavde = min( min( r+1, c+1 ), min( n-r, m-c ) );  
            if ( 2*max_odavde+x <= ret ) {  
               // Nema smisla pokusavati se siriti iz ovog polja jer je  
               // najveci moguci kvadrat nije vec vec nadenog ubojice  
               continue;  
            }  
            int size = x;  
            while( check( r-size/2, c-size/2, size ) )  
               size += 2;  
            ret >?= size-1;  
         }  
   }  
   if ( ret > 1 )  
      printf( "%d\n", ret );  
   else  
      printf( "-1\n" );  
   return 0;  
}  

[/codec]

Diagonal

[codep]

var  
  i,j,k,m,n,s,t:longint;  
begin  
  read(n);  
  writeln(n*(n-1)*(n-2)*(n-3) div 24);  
end.  
[/codep]
2014/10/2 13:57
加载中...