锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲va久久久噜噜噜久久,亚洲AV无码1区2区久久,精品乱码久久久久久久http://m.shnenglu.com/goAheadtw/category/15892.htmlhahazh-cnWed, 19 Jan 2011 03:26:21 GMTWed, 19 Jan 2011 03:26:21 GMT60Timus 1087(recursion game)http://m.shnenglu.com/goAheadtw/articles/138752.htmltwtwTue, 18 Jan 2011 07:23:00 GMThttp://m.shnenglu.com/goAheadtw/articles/138752.htmlhttp://m.shnenglu.com/goAheadtw/comments/138752.htmlhttp://m.shnenglu.com/goAheadtw/articles/138752.html#Feedback0http://m.shnenglu.com/goAheadtw/comments/commentRss/138752.htmlhttp://m.shnenglu.com/goAheadtw/services/trackbacks/138752.html1087. The Time to Take Stones
Time Limit: 1.0 second
Memory Limit: 16 MB
You probably know the game where two players in turns take 1 to 3 stones from a pile. Looses the one who takes the last stone. We'll generalize this well known game. Assume that both of the players can take not 1, 2 or 3 stones, but k1, k2, …, km ones. Again we'll be interested in one question: who wins in the perfect game. It is guaranteed that it is possible to make next move irrespective to already made moves.

Input

The first line contains two integers: n and m (1 ≤ n ≤ 10000; 1 ≤ m ≤ 50) 鈥?they are an initial amount of stones in the pile and an amount of numbers k1, …, km. The second line consists of the numbers k1, …, km, separated with a space (1 ≤ kin).

Output

Output 1, if the first player (the first to take stones) wins in a perfect game. Otherwise, output 2.

Sample

input output
17 3
            1 3 4
            
2
            
Problem Author: Anton Botov
Problem Source: The 3rd high school children programming contest, USU, Yekaterinburg, Russia, March 4, 2001



/*
"Looses the one who takes the last stone" 鈥斺?nbsp;the one takes the last 
stone loses the game ! 
*/ 
#include 
<stdio.h>
#include 
<memory>
#include 
<iostream>
#include 
<algorithm>
#include 
<cstring>
#include 
<vector>
#include 
<map>
#include 
<cmath>
#include 
<set>
#include 
<queue>
#include 
<time.h> 
#include 
<limits>
using namespace std; 
#define N 10005
#define M 55
int step[M], n, m; 
bool state[N]; 
bool input(){
    
if(scanf("%d%d"&n, &m) == EOF) return false
    
int i; 
    
for(i = 0; i < m; i++) scanf("%d", step+i);
    
return true
}
void solve(){
    memset(state, 
0sizeof(bool* (n+1)); 
    
int i, j, u; 
    
for(i = 1; i <= n; i++){
        
for(j = 0; j < m; j++){
            
if((u = i - step[j]) >= 0){
                
if(u == 0){
                    state[i] 
= false
                }
else{
                    
if(!state[u]){
                        state[i] 
= true
                        
break
                    }
                }
            }
        }
    }
    
//for(i = 0; i <= n; i++) printf("s[%d]=%d\n", i, state[i]);
    if(state[n]) printf("1\n");
    
else printf("2\n");
}
int main(){
#ifndef ONLINE_JUDGE
    freopen(
"in.txt""r", stdin); 
    
//freopen("out.txt", "w", stdout); 
#endif 
    
while(input()) solve(); 
    
return 0;
}



tw 2011-01-18 15:23 鍙戣〃璇勮
]]>
Timus 1045 (game on a tree)http://m.shnenglu.com/goAheadtw/articles/138667.htmltwtwMon, 17 Jan 2011 06:13:00 GMThttp://m.shnenglu.com/goAheadtw/articles/138667.htmlhttp://m.shnenglu.com/goAheadtw/comments/138667.htmlhttp://m.shnenglu.com/goAheadtw/articles/138667.html#Feedback0http://m.shnenglu.com/goAheadtw/comments/commentRss/138667.htmlhttp://m.shnenglu.com/goAheadtw/services/trackbacks/138667.html 

#include <stdio.h>
#include 
<memory>
#include 
<iostream>
#include 
<algorithm>
#include 
<cstring>
#include 
<vector>
#include 
<map>
#include 
<cmath>
#include 
<set>
#include 
<queue>
#include 
<time.h> 
#include 
<limits>
using namespace std; 
#define N 1005
struct e{
    
int v; 
    e
* nxt; 
}es[N
*2];
e
* fir[N]; 
int en, n, st, l; 
bool state[N]; 
inline 
void add_e(int u, int v){
    es[en].v 
= v; es[en].nxt = fir[u]; fir[u] = &es[en++]; 
}
bool input(){
    
if(scanf("%d%d"&n, &st) == EOF) return false
    st
--
    
int i, u, v; 
    
for(i = 0; i < n; i++) fir[i] = NULL; 
    en 
= 0
    
for(i = 1; i < n; i++){
        scanf(
"%d%d"&u, &v);
        u
--
        v
--
        add_e(u, v);
        add_e(v, u); 
    }
    
return true
}
void dfs(int u, int fa){
    e
* cur; 
    
int v; 
    
bool hasSon = false
    
for(cur = fir[u]; cur; cur = cur->nxt){
        
if((v = cur->v) != fa){
            hasSon 
= true
            dfs(v, u); 
        }
    }
    
if(!hasSon){
        state[u] 
= false;   //蹇呰觸鎬?/span>
    }else{
        state[u] 
= false
        
for(cur = fir[u]; cur; cur = cur->nxt){
            
if((v = cur->v) != fa){
                
if(!state[v]){
                    
if(u == st){
                        
if(state[u]){
                            
if(l > v + 1) l = v + 1
                        }
else{
                            state[u] 
= true
                            l 
= v + 1
                        }
                    }
else state[u] = true
                }
            }
        }
    }
}
void solve(){
    dfs(st, 
-1); 
    
if(state[st]) printf("First player wins flying to airport %d\n", l);
    
else printf("First player loses\n");
}
int main(){
#ifndef ONLINE_JUDGE
    freopen(
"in.txt""r", stdin); 
    
//freopen("out.txt", "w", stdout); 
#endif 
    
while(input()) solve(); 
    
return 0;
}





tw 2011-01-17 14:13 鍙戣〃璇勮
]]>
Timus 1023(Bash Game)http://m.shnenglu.com/goAheadtw/articles/138665.htmltwtwMon, 17 Jan 2011 05:24:00 GMThttp://m.shnenglu.com/goAheadtw/articles/138665.htmlhttp://m.shnenglu.com/goAheadtw/comments/138665.htmlhttp://m.shnenglu.com/goAheadtw/articles/138665.html#Feedback0http://m.shnenglu.com/goAheadtw/comments/commentRss/138665.htmlhttp://m.shnenglu.com/goAheadtw/services/trackbacks/138665.html// bash game
#include <stdio.h>
#include <memory>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <time.h>
#include <limits>
using namespace std;
int cal(int a){
 int b, ans;
 ans = inf;
 for(b = 1; b * b <= a; b++){
  if(!(a % b)){
   if(b > 2 && b < ans) ans = b;
   if((a / b) > 2 && (a / b) < ans) ans = (a / b);
  }
 }
 if(ans < inf) return ans - 1;
 else return a - 1;
}
int main(){
#ifndef ONLINE_JUDGE
 //freopen("in.txt", "r", stdin);
 //freopen("out.txt", "w", stdout);
#endif
 init();
 int a;
 while(~scanf("%d", &a)){
  printf("%d\n", cal(a));
 }
 return 0;
}

 

 



tw 2011-01-17 13:24 鍙戣〃璇勮
]]>
四虎国产精品成人免费久久| 性欧美丰满熟妇XXXX性久久久| 精品亚洲综合久久中文字幕| 亚洲综合精品香蕉久久网97| 精品无码久久久久久久动漫| 性做久久久久久久久| 久久亚洲私人国产精品vA | 色偷偷888欧美精品久久久| 天天综合久久久网| yy6080久久| 国产精品VIDEOSSEX久久发布| 亚洲精品无码久久久| 久久精品国产亚洲av高清漫画 | 亚洲精品无码专区久久久| 久久精品国产半推半就| 久久精品一区二区三区AV| 久久综合九色综合精品| 色综合久久综合中文综合网| 久久久久久一区国产精品| 丰满少妇人妻久久久久久| 久久国产亚洲精品| 9久久9久久精品| 国产精品久久久久a影院| 国产精品欧美久久久久无广告| 久久婷婷激情综合色综合俺也去| 四虎影视久久久免费观看| 狠狠色丁香婷婷综合久久来来去| 久久水蜜桃亚洲av无码精品麻豆| 亚洲欧美日韩精品久久亚洲区| 久久99精品久久久久久水蜜桃| 久久精品国产91久久麻豆自制| 久久久老熟女一区二区三区| 欧洲精品久久久av无码电影| 久久久久久精品无码人妻| 亚洲性久久久影院| 青青草原综合久久大伊人导航 | 久久人人爽人人爽人人片AV东京热 | 91久久香蕉国产熟女线看| 国产精品天天影视久久综合网| 东京热TOKYO综合久久精品| 久久久久亚洲av无码专区导航 |