随笔分类 - 
        
            模拟
        
    
        
            
    HDU 4054
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4054模拟题,对一个字符串的每个字符输出16进制表示的数字,每行处理16个字符,后面再把这16个字符输出,大小写互换利用%x可以直接输出16进制,轻松秒掉#include #include #include #in...
         阅读全文
 
            
         
        
            
    HDU 4068
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4068暴力枚举两个全排列,犯了若干错误,以此为鉴#include #include #include #include using namespace std ;int n,f,m[10],vis[10],vis2...
         阅读全文
 
            
         
        
            
    HDU 1073
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1073模拟oj判题随便搞,开始字符串读入的细节地方没处理好,wa了好久#include #include #include #include using namespace std ; char s1[100005...
         阅读全文
 
            
         
        
            
    HDU 3378
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3378规则去玩三国杀就理解了纯模拟注意的点:有已经分出胜负但还在杀的情况出现,所以要每次杀操作前判断是否分出胜负,如果已经分出胜负了就continue,不用接着往下操作#include #include #include using namespace std ;int n ;typedef struct L{ char js[5] ; int al ; int esc ; int sc ;}L ;L kk[101] ;int pk ;int bjnj,wnj ;int ok(){ ...
         阅读全文
 
            
         
        
            
    hdu 4121
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4121中国象棋的简单模拟,给出黑方仅存的老帅坐标,再给出红方棋子坐标,问是否把黑方将死。输入数据有多余空格,所以要用cin,不能用scanf,这块错惨了#include using namespace std ;int abs(int x){ return x>0?x:-x ;}char map[11][11] ;int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}} ;int RGX,RGY ;int xx,yy ;int ok(int x,int y){ if(y!...
         阅读全文
 
            
         
        
            
    HDU 1033
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1033这题的题干说的很绕,结合样例不难理解题意,走折线,A代表顺时针,V代表逆时针,给一个包含A和V的字符串,输出走过的点。不难发现,不管是顺时针走还是逆时针走,x和y坐标的变化都是不一定的。而根据折线的特点我们知道单纯的向一个方向走的周期是4,沿着这个思路模拟出坐标变化就容易多了#include #include using namespace std ;char a[2001] ;int sx,sy ;int flag ;int len ;int main(){ while(~scanf("%s
         阅读全文
 
            
         
        
            
    POJ 1951
    
            
摘要:把给定字符串翻译成目标字符串需要满足的条件是:1、开头不能有空格2、末尾不能有空格3、给定标点前不能有空格4、不能有A、E、I、O、U5、空格不能和空格相邻6、相同的字母只能出现1次给出一组测试数据('_'表示空格):input_I_AM_M._outputM.这道题是水题,但是我忽视了一点导致错误。形如"_I_AM_M._"这个输入。我开始的方法是从头扫空格,遇到字母就停下,这样I前的空格很容易就去掉了,但是像此种情况,I和A都是要去掉的字母,而I和A之间又有空格,这样的结果就是输出的M前会多一个空格,PE。避免这种错误的方法很简单,只要得要ans数组以后
         阅读全文
 
            
         
        
            
    HDU 2164 Rock, Paper, or Scissors?
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2164剪刀石头布,无脑模拟View Code #include <stdio.h>int gao(char p1,char p2){ if(p1=='S'&&p2=='P')return 1; if(p1=='P'&&p2=='R')return 1; if(p1=='R'&&p2=='S')return 1; if(p2=='S'&
         阅读全文
 
            
         
        
            
    HDU 2537 8球胜负
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2537模拟View Code #include <stdio.h>char a[100];int n;int gao(){ int r,y,i; r=y=7; for(i=0;i<n;i++) { if(a[i]=='R')r--; if(a[i]=='Y')y--; if(a[i]=='B'&&r==0)return 1; if(a[i]=='B'&&r!=0)return 0; if(a[i]
         阅读全文
 
            
         
        
            
    HDU 1691 Chinese Chess
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1691博客里面不好骂人,所以就不说太多了。有几点注意:1、象可能跑到不可能达到的位置2、兵要判断后退这种情况View Code 1 #include <stdio.h> 2 3 int map[20][20]; 4 int Kinga,Kingb;//红王坐标 5 int Kingc,Kingd;//黑王坐标 6 int abs(int a){return a>0?a:-a;} 7 int KingFaceToFace()//两王是否相对 8 { 9 int i; 10 ...
         阅读全文
 
            
         
        
            
    HDU 1283 最简单的计算机
    
            
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1283模拟View Code #include <stdio.h>int main() { int m1,m2,r1,r2,r3,i; char s[300]; while(~scanf("%d%d",&m1,&m2)) { scanf("%s",s); r1=r2=r3=0; for(i=0;s[i];i++) { switch(s[i]) { ...
         阅读全文
 
            
         
    
 
    
 
 |