↓ 跳过正文
  1. Posts/

bc #52 div 2 A ||hdoj5417 Victor and Machine (模拟)

·262 字·1 分钟

傻逼模拟题

我做了半小时….

sssssad

代码实现
 1/*************************************************************************
 2	> File Name: code/bc/#52/1001.cpp
 3	> Author: 111qqz
 4	> Email: rkz2013@126.com
 5	> Created Time: 2015年08月22日 星期六 18时51分44秒
 6 ************************************************************************/
 7#include<iostream>
 8#include<iomanip>
 9#include<cstdio>
10#include<algorithm>
11#include<cmath>
12#include<cstring>
13#include<string>
14#include<map>
15#include<set>
16#include<queue>
17#include<vector>
18#include<stack>
19#include<cctype>
20#define y1 hust111qqz
21#define yn hez111qqz
22#define j1 cute111qqz
23#define ms(a,x) memset(a,x,sizeof(a))
24#define lr dying111qqz
25using namespace std;
26#define For(i, n) for (int i=0;i<int(n);++i)
27typedef long long LL;
28typedef double DB;
29const int inf = 0x3f3f3f3f;
30const int N=1E6+7;
31int main()
32{
33  #ifndef  ONLINE_JUDGE
34    freopen("in.txt","r",stdin);
35  #endif
36    int x,y,w,n;
37    while (scanf("%d%d%d%d",&x,&y,&w,&n)!=EOF){
38	int num = 1;
39	int cnt;
40	int q;
41	bool on = true;
42	bool flag = false;
43	int t = 0;
44	while (t<N&&!flag){
45	    if (num==n) {
46		cout<<t<<endl;
47		flag = true;
48		break;
49	    }
50	    cnt = t+x;
51	    q =  0;
52	    while (t<cnt){
53		q++;
54		t++;
55		if (q%w==0){
56//		     cout<<"aaat:"<<t<<endl;
57		     num++;
58		}
59	    if (num == n){
60		cout<<t<<endl;
61		flag = true;
62		break;
63	    }
64	    }
65	    on = false;
66	    t = t + y;
67	    on = true;
68	    num++;
69	    if (num==n){
70		cout<<t<<endl;
71		flag = true;
72	    }
73	}
74    }
75 #ifndef ONLINE_JUDGE
76  fclose(stdin);
77  #endif
78	return 0;
79}

相关文章

codeforces 560 B. Gerald is into Art (模拟)

·135 字·1 分钟
代码实现 1/************************************************************************* 2 > File Name: code/cf/#313/B.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: Wed 22 Jul 2015 09:52:54 PM CST 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#define y0 abc111qqz 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define tm crazy111qqz 25#define lr dying111qqz 26using namespace std; 27#define REP(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef unsigned long long ULL; 30 31 int a1,b1,a2,b2,a3,b3; 32bool judge (int x2,int y2,int x3,int y3) 33{ 34 if (x2<=a1&&x3<=a1&&y2+y3<=b1) 35 return true; 36 if (y2<=b1&&y3<=b1&&x2+x3<=a1) 37 return true; 38 return false; 39} 40int main() 41{ 42 cin>>a1>>b1>>a2>>b2>>a3>>b3; 43 if (judge(a2,b2,a3,b3)||judge(b2,a2,a3,b3)||judge(b2,a2,b3,a3)||judge(a2,b2,b3,a3)) 44 { 45 puts("YES"); 46 } 47 else 48 { 49 puts("NO"); 50 } 51 52 return 0; 53}

codeforces 314 D One-Dimensional Battle Ships (模拟)

·807 字·2 分钟
比赛的时候没搞出来,really sad. 其实这题很容易啊.... 首先,对于lie 的判断应该基于能放的船的个数. 能放的船的个数是随着射的点数的增加而减少的. 射完每个点后更新能放的船的个数,如果这个时候已经无法放下k条船了,说明lie了. 如果所有都射完也没发生,那么就-1.

cf #314 B. Berland National Library (模拟)

·456 字·1 分钟
给出一个图书馆人员进出情况,问图书馆满足题意的最小容量是多少。 注意在初始之前图书馆里面可能就有人了,也就是说不是所有进入图书馆的人都会被给出。 我的做法是先统计出图书馆里面初始的人数,开一个布尔数组,初始全为false,如果一个人标记为 false 而且从 图书馆里出来了,就说明这个人初始是在图书馆里的。

sgu 463 - Walking around Berhattan

·625 字·2 分钟
简单模拟,n,m貌似给反了(两个地方给的不一致 ) 害我wa了两发 代码实现 1 2 /************************************************************************* 3 > File Name: code/2015summer/#5/K.cpp 4 > Author: 111qqz 5 > Email: rkz2013@126.com 6 > Created Time: 2015年07月30日 星期四 14时00分56秒 7 ************************************************************************/ 8 9 #include<iostream> 10 #include<iomanip> 11 #include<cstdio> 12 #include<algorithm> 13 #include<cmath> 14 #include<cstring> 15 #include<string> 16 #include<map> 17 #include<set> 18 #include<queue> 19 #include<vector> 20 #include<stack> 21 #define y0 abc111qqz 22 #define y1 hust111qqz 23 #define yn hez111qqz 24 #define j1 cute111qqz 25 #define tm crazy111qqz 26 #define lr dying111qqz 27 using namespace std; 28 #define REP(i, n) for (int i=0;i<int(n);++i) 29 typedef long long LL; 30 typedef unsigned long long ULL; 31 const int inf = 0x7fffffff; 32 const int N=1e2+5; 33 int b[N][N]; 34 int n,m; 35 char cmd[505]; 36 bool vis[N][N]; 37 int nx,ny; 38 int dx[4]={-1,0,1,0}; 39 int dy[4]={0,1,-0,-1}; 40 char ch[N][N]; 41 int main() 42 { 43 cin>>n>>m; 44 nx = 0; 45 ny = 0; 46 for ( int i = 0 ; i < n ; i++) 47 cin>>ch[i]; 48 for ( int i = 0 ; i <n ; i++ ) 49 { 50 for ( int j = 0 ; j < m ; j++ ) 51 { 52 b[i+1][j+1]=(int)(ch[i][j]-'0'); 53 } 54 } 55 int ans = 0; 56 memset(vis,false,sizeof(vis)); 57 int dir = 1; 58 cin>>cmd; 59 int len = strlen(cmd); 60 for ( int i = 0 ; i < len ; i ++ ) 61 { 62 // cout<<"ans:"<<ans<<endl; 63 // cout<<"nx:"<<nx<<" ny:"<<ny<<endl; 64 if (cmd[i]=='L') 65 { 66 dir = (dir+3)%4; 67 } 68 if (cmd[i]=='R') 69 { 70 dir = (dir+1)%4; 71 } 72 if (cmd[i]=='M') 73 { 74 if (dir==0) 75 { 76 if (vis[nx][ny]) 77 { 78 ans = ans + b[nx][ny]/2; 79 } 80 else 81 { 82 ans = ans + b[nx][ny]; 83 } 84 if (vis[nx][ny+1]) 85 { 86 ans = ans + b[nx][ny+1]/2; 87 } 88 else 89 { 90 ans = ans + b[nx][ny+1]; 91 } 92 vis[nx][ny]=true; 93 vis[nx][ny+1]=true; 94 nx = nx +dx[dir]; 95 ny = ny +dy[dir]; 96 } 97 if (dir==2) 98 { 99 nx = nx + dx[dir]; 100 ny = ny + dy[dir]; 101 if (vis[nx][ny]) 102 { 103 ans = ans + b[nx][ny]/2; 104 } 105 else 106 { 107 ans = ans + b[nx][ny]; 108 } 109 if (vis[nx][ny+1]) 110 { 111 ans = ans + b[nx][ny+1]/2; 112 } 113 else 114 { 115 ans = ans + b[nx][ny+1]; 116 } 117 vis[nx][ny]=true; 118 vis[nx][ny+1]=true; 119 } 120 if (dir==1) 121 { 122 nx = nx + dx[dir]; 123 ny = ny + dy[dir]; 124 if (vis[nx][ny]) 125 { 126 ans = ans + b[nx][ny]/2; 127 } 128 else 129 { 130 ans = ans + b[nx][ny]; 131 } 132 if (vis[nx+1][ny]) 133 { 134 ans = ans + b[nx+1][ny]/2; 135 } 136 else 137 { 138 ans = ans + b[nx+1][ny]; 139 } 140 vis[nx][ny]=true; 141 vis[nx+1][ny]=true; 142 143 } 144 if (dir==3) 145 { 146 147 if (vis[nx][ny]) 148 { 149 ans = ans + b[nx][ny]/2; 150 } 151 else 152 { 153 ans = ans + b[nx][ny]; 154 } 155 if (vis[nx+1][ny]) 156 { 157 ans = ans + b[nx+1][ny]/2; 158 } 159 else 160 { 161 ans = ans + b[nx+1][ny]; 162 } 163 vis[nx][ny]=true; 164 vis[nx+1][ny]=true; 165 nx = nx +dx[dir]; 166 ny = ny +dy[dir]; 167 } 168 } 169 170 } 171 cout<<ans<<endl; 172 173 return 0; 174 }