锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
#include<iostream>
#include<string>
#define DEBUG 1
using namespace std ;
const int cap = 33 ;
char salon[cap] ;
string in ;
int check( int avai )

{
int i, j, pos(-1), flag, away(0) ;
for( i=0; i<in.size(); ++i )
{
if( i >= 1 )
pos = in.rfind( in[i], i ) ;
if( pos >= 0 )
{
flag = 0 ;
for( j=0; j<avai; ++j )
{
if( salon[j] == in[i] )
{
salon[j] = '\0' ;
flag = 1 ;
break ;
}
}
if( !flag )
{
for( j=0; j<avai; ++j )
{
if( !salon[j] )
{
flag = 1 ;
break ;
}
}
}
if( !flag )
++away ;
}
else
{
for( j=0; j<avai; ++j )
{
if( !salon[j] )
{
salon[j] = in[i] ;
break ;
}
}
}
}
return away ;
}
void output( int away )

{
if( away )
cout << away << " customer(s) walked away." << endl ;
else
cout << "All customers tanned successfully." << endl ;
}
int main( )

{
#if DEBUG
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\in.in","r",stdin) ;
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\out.out","w",stdout) ;
#endif
int avai, away ;
while( cin >> avai )
{
if( avai == 0 )
break ;
cin >> in ;
away = check( avai ) ;
output( away ) ;
}
return 0 ;
}
]]>
榪欎釜棰樻暟鎹噺涓嶅ぇ錛屽彲浠ョ敤鍥炴函銆傚垰寮濮嬪仛鐨勬椂鍊欙紝鏄敤騫挎悳錛屼絾鏄啓璧鋒潵瓚呴夯鐑︼紝浠g爜閲忔瀬澶э紝寰堝鏄撳嚭閿欍傚弬鑰冧簡澶х墰浠殑鍋氭硶錛屾墠鎯寵搗鏉ュ拰N鐨囧悗闂寰堝儚銆傛垜浠彲浠ヤ粠涓涓偣鍑哄彂錛岀劧鍚庡線鍙充笅鎵╂暎錛屾墿鏁e畬浜嗕箣鍚庯紝鍐嶅洖婧紝鍐嶆墿鏁?#8230;… 闂瑙e喅銆?/font>
#include<iostream>
#define DEBUG 0
using namespace std ;
int n, maxi ;
char a[5][5] ;
bool legal( int x, int y )

{
int i, j ;
for( i=x-1; i>=0; --i )
{
if( a[i][y] == '@' )
return false ;
else if( a[i][y] == 'X' )
break ;
}
for( j=y-1; j>=0; --j )
{
if( a[x][j] == '@' )
return false ;
else if( a[x][j] == 'X' )
break ;
}
return true ;
}
void trace( int x, int y, int geshu )

{
if( x == n )
maxi = maxi>geshu ? maxi:geshu ;
else
{
if( y == n )
trace( x+1, 0, geshu ) ;
else
{
if( a[x][y]=='.' && legal( x, y ) )
{
// 鍥炴函鏍囪
a[x][y] = '@' ;
trace( x, y+1, geshu+1 ) ;
a[x][y] = '.' ;
}
trace( x, y+1, geshu ) ;
}
}
}
int main()

{
#if DEBUG
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\in.in","r",stdin) ;
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\out.out","w",stdout) ;
#endif
int i, j ;
while( cin >> n )
{
if( !n )
break ;
for( i=0; i<n; ++i )
{
for( j=0; j<n; ++j )
{
cin >> a[i][j] ;
}
}
maxi = 0 ;
// 浠?錛?寮濮嬪洖婧?nbsp;
trace( 0, 0, 0 ) ;
cout << maxi << endl ;
}
return 0 ;
}
#include<iostream>
#include<cmath>
using namespace std ;
int n, a[111], k, ans[22], anscnt ;
int p[42]=
{0,0,2,3,0,5,0,7,0,0,0,11,0,13,0,0,0,17,0,19,0,
0,0,23,0,0,0,0,0,29,0,31,0,0,0,0,0,37,0,0,0,41} ;
int rev[100][20], revcnt ;
void DFS( int m, int geshu )

{
int i, j ;
if( geshu == n && p[1+m] )
{
cout << ans[0] ;
for( i=1; i<n; ++i )
{
cout << " " << ans[i] ;
rev[revcnt][i] = ans[i] ;
}
++revcnt ;
cout << "\n" ;
}
else if( geshu == n )
return ;
for( j=2; j<=n; ++j )
{
if( j<p[j+m] && !a[j] )
{
a[j] = 1 ;
ans[geshu] = j ;
DFS( j, geshu+1 ) ;
a[j] = 0 ;
}
}
}
int main( )

{
int i, j ;
for( j=1; cin >> n; ++j )
{
cout << "Case "<< j << ":\n" ;
for( i=0; i<111; ++i )
a[i] = 0 ;
revcnt = 0 ;
k = 1 ;
ans[0] = 1 ;
anscnt = 1 ;
DFS( 1, 1 ) ;
cout << "\n";
}
return 0 ;
}
浠婂ぉ緇堜簬鍙堝仛浜嗕竴涓笉鏄緢姘寸殑棰樼洰錛屾暟璁虹殑錛屽ぇ鏁存暟鍙栦綑錛岀洿鎺ユ毚鍔涜繃浜嗐傚叾涓張瀛︿簡涓縐嶇礌鏁扮殑絳涢夋硶錛屾晥鐜囨瘮鎴戜互鍓嶇敤鐨勬柟娉曢兘瑕侀珮銆備粬涓嶈綆楋紝鍙槸絳涢夈傝繖鏍蜂竴鏉ユ晥鐜囧氨楂樹簡寰堝銆傝繕鏈変竴涓湴鏂癸紝灝辨槸澶ф暣鏁扮殑鍙栦綑錛屼粠楂樹綅錛屽埌浣庝綅錛岃竟涔樿竟鍙栦綑錛屾牴鎹殑鏄悓浣欏畾鐞嗐?/font>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int p[1000000] ;
char pr[1000000] ;
int len, pnum, num[14] ;
void prime( )

{
int i, j ;
// 絳涢夌礌鏁?nbsp;
for( i=2; i<1000000; ++i )
{
pr[i] = 1 ;
}
for( i=2,pnum=0; i<1000000; ++i )
{
if( pr[i] )
{
p[pnum++] = i ;
for( j=i+i; j<1000000; j+=i )
pr[j] = 0 ;
}
}
}
int mod( int n )

{
__int64 m=0 ;
int i ;
// 姹備綑鏁?nbsp;
for( i=len-1; i>=0; --i )
{
m = ( m*100000000+num[i] ) % n ;
}
return m ;
}
int main()

{
char a[111] ;
int i, j, div, flag ;
prime( ) ;

while( scanf("%s%d", a, &div ) && div && a[0]!='0' )
{
len = strlen( a ) ;
for( i=0; i<14; ++i )
num[i] = 0 ;
for( i=0; i<len; ++i )
{
//閫竴浜胯繘浣?nbsp;
j = (len+7-i) / 8 - 1 ;
num[j] = num[j]*10 + a[i]-'0' ;
}
len = (len+7)/8 ;
flag = 1 ;
for( i=0; p[i]<div && i<pnum; ++i )
{
if( mod( p[i] ) == 0 )
{
flag = 0 ;
break ;
}
}
if( flag )
printf("GOOD\n") ;
else
printf("BAD %d\n", p[i] ) ;
}
system("pause");
return 0 ;
}
#include <stdio.h>
#define DEBUG 1
int main()

{
#if DEBUG
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\in.in","r",stdin) ;
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\out.out","w",stdout) ;
#endif
__int64 i, n, sets, s, fenmu ;
double p, temp ;
scanf("%I64d", &sets ) ;
while( sets-- )
{
scanf("%I64d", &n ) ;
p = 1 ;
s = 1 ;
fenmu = 1 ;
for( i=1; i<=n; ++i )
{
s *= -1 ;
fenmu *= i ;
p += s/(double)fenmu ;
}
printf("%.2lf%%\n", 100*p ) ;
}
}
#include <stdio.h>
#define DEBUG 1
int main()

{
#if DEBUG
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\in.in","r",stdin) ;
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\out.out","w",stdout) ;
#endif
__int64 i, n, s, geshu, a1, a2, temp ;
while( EOF != scanf("%I64d", &n ) )
{
a1 = 0 ;
a2 = 1 ;
for( i=1; i<=n; ++i )
{
temp = a2 ;
a2 = (i-1) * (a1+a2) ;
a1 = temp ;
}
printf("%I64d\n", a2 ) ;
}
return 0 ;
}
#include <stdio.h>
#include <math.h>
#define DEBUG 1
short a[1000000] ;
int main()

{
#if DEBUG
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\in.txt","r",stdin);
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\out.txt","w",stdout);
#endif
int i, j, n, flag ;
double temp ;
for( i=2; i<1000000; ++i )
{
if( a[i] )
continue ;
for( j=i; j<1000000; j+=i )
a[j] = 1 ;
temp = sqrt( i ) ;
flag = 1 ;
for( j=2; j<=temp; ++j )
{
if( i%j == 0 )
{
flag = 0 ;
break ;
}
}
if( flag )
a[i] = 0 ;
}
while( scanf("%d", &n ) && n )
{
for( i=3; i<n; i+=2 )
{
if( !a[i] && !a[n-i] )
{
printf("%d = %d + %d\n", n, i, n-i ) ;
break ;
}
}
}
return 0 ;
}
#include <stdio.h>
#include <string.h>
#include <memory.h>
#define DEBUG 1
const int N=28 ;
int map[N][N] ;
void Floyd( )

{
int i, j, k ;
for( k=0; k<26; ++k )
for( i=0; i<26; ++i )
for( j=0; j<26; ++j )
map[i][j] = map[i][j] || ( map[i][k] && map[k][j] ) ;
}
int main()

{
#if DEBUG
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\in.txt","r",stdin);
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\out.txt","w",stdout);
#endif
int len ;
char a[2000] ;
while( EOF != scanf("%s",a) )
{
if( a[0] == '0' )
{
Floyd( ) ;
if( map[1][12] )
printf("Yes.\n") ;
else
printf("No.\n") ;
memset( map, 0, sizeof(map) ) ;
continue ;
}
len = strlen( a ) ;
map[a[0]-'a'][a[len-1]-'a'] = 1 ;
}
return 0 ;
}
#include <stdio.h>
#include <string.h>
#include <memory.h>
#define DEBUG 1
int n ;
char mo[31][30] ;
double map[31][31] ; 
int Find( char *t )

{
int i ;
for( i=1; i<=n; ++i )
if( !strcmp( mo[i], t ) )
return i ;
}
void Floyd( )

{
int i, j, k ;
for( k=1; k<=n; ++k )
for( i=1; i<=n; ++i )
for( j=1; j<=n; ++j )
if( map[i][j] < map[i][k]*map[k][j] )
map[i][j] = map[i][k]*map[k][j] ;
}
void In( )

{
int i, x, y, sets ;
char a[30], b[30] ;
double rate ;
for( i=1; i<=n; ++i )
scanf("%s", mo[i] ) ;
scanf("%d", &sets ) ;
for( i=1; i<=sets; ++i )
{
scanf("%s %lf %s", a, &rate, b ) ;
x = Find( a ) ;
y = Find( b ) ;
map[x][y] = rate ;
}
}
void Judge( )

{
int flag, i ;
flag = 0 ;
for( i=1; i<=n; ++i )
{
if( map[i][i] >= 1 )
{
flag = 1 ;
break ;
}
}
if( flag )
printf("Yes\n") ;
else
printf("No\n") ;
}
int main()

{
#if DEBUG
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\in.in","r",stdin) ;
freopen("C:\\Documents and Settings\\Administrator\\妗岄潰\\out.out","w",stdout) ;
#endif
int i ;
for( i=1; scanf("%d", &n) && n; ++i )
{
printf("Case %d: ", i ) ;
memset( map, 0, sizeof(map) ) ;
In( ) ;
Floyd( ) ;
Judge( ) ;
}
return 0 ;
}