-
Notifications
You must be signed in to change notification settings - Fork 0
/
solution1.html
244 lines (193 loc) · 16.9 KB
/
solution1.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>Problem Solution</title>
<link rel='stylesheet' id='crayon-css' href='http://zakilive.com/wp-content/plugins/crayon-syntax-highlighter/css/min/crayon.min.css?ver=_2.7.2_beta' type='text/css' media='all' />
<link rel='stylesheet' id='crayon-theme-classic-css' href='http://zakilive.com/wp-content/plugins/crayon-syntax-highlighter/themes/classic/classic.css?ver=_2.7.2_beta' type='text/css' media='all' />
<link rel='stylesheet' id='crayon-font-monaco-css' href='http://zakilive.com/wp-content/plugins/crayon-syntax-highlighter/fonts/monaco.css?ver=_2.7.2_beta' type='text/css' media='all' />
<link rel='stylesheet' id='all-css-2-1' href='https://s0.wp.com/_static/??-eJyFjMEOwjAMQ3+IEoY0NA6Ib+lK6AJpUy2ppv093W1c4GDJlu0HS3FBsmE2sAkTKpQ6bmLSCdRWxmNQPcBumKorXCNlhYUeEU0Ba2vlTejYL2CYCntrsL+AiOJYgjeS/BXckz3Nv64zjiyx2QhttYvb6Z5uXX89dZf+PAyvD7s5VgA=?cssminify=yes' type='text/css' media='all' />
<style id='jetpack-global-styles-frontend-style-inline-css'>
:root { --font-headings: unset; --font-base: unset; --font-headings-default: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; --font-base-default: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;}
</style>
<link rel='stylesheet' id='all-css-4-1' href='https://s0.wp.com/wp-content/themes/h4/global.css?m=1420737423h&cssminify=yes' type='text/css' media='all' />
<script id='wpcom-actionbar-placeholder-js-extra'>
var actionbardata = {"siteID":"55232210","siteName":"Algorithm challenge","siteURL":"http:\/\/saicheems.wordpress.com","icon":"<img alt='' src='https:\/\/s0.wp.com\/i\/logo\/wpcom-gray-white.png' class='avatar avatar-50' height='50' width='50' \/>","canManageOptions":"","canCustomizeSite":"","isFollowing":"","themeSlug":"pub\/publish","signupURL":"https:\/\/wordpress.com\/start\/","loginURL":"https:\/\/wordpress.com\/log-in?redirect_to=https%3A%2F%2Fsaicheems.wordpress.com%2F2014%2F08%2F23%2Fuva-11854-egypt%2F&signup_flow=account","themeURL":"","xhrURL":"https:\/\/saicheems.wordpress.com\/wp-admin\/admin-ajax.php","nonce":"aea24a9396","isSingular":"","isFolded":"","isLoggedIn":"","isMobile":"","subscribeNonce":"<input type=\"hidden\" id=\"_wpnonce\" name=\"_wpnonce\" value=\"8d6593076b\" \/>","referer":"https:\/\/saicheems.wordpress.com\/","canFollow":"1","feedID":"12851767","statusMessage":"","customizeLink":"https:\/\/saicheems.wordpress.com\/wp-admin\/customize.php?url=https%3A%2F%2Fsaicheems.wordpress.com%2F","i18n":{"view":"View site","follow":"Follow","following":"Following","edit":"Edit","login":"Log in","signup":"Sign up","customize":"Customize","report":"Report this content","themeInfo":"Get theme: Publish","shortlink":"Copy shortlink","copied":"Copied","followedText":"New posts from this site will now appear in your <a href=\"https:\/\/wordpress.com\/read\">Reader<\/a>","foldBar":"Collapse this bar","unfoldBar":"Expand this bar","editSubs":"Manage subscriptions","viewReader":"View site in Reader","viewReadPost":"View post in Reader","subscribe":"Sign me up","enterEmail":"Enter your email address","followers":"","alreadyUser":"Already have a WordPress.com account? <a href=\"https:\/\/wordpress.com\/log-in?redirect_to=https%3A%2F%2Fsaicheems.wordpress.com%2F2014%2F08%2F23%2Fuva-11854-egypt%2F&signup_flow=account\">Log in now.<\/a>","stats":"Stats"}};
</script>
<script type='text/javascript' src='https://s0.wp.com/_static/??/wp-includes/js/jquery/jquery.js,/wp-content/js/postmessage.js,/wp-content/js/mobile-useragent-info.js?m=1558356653j'></script>
<link rel='stylesheet' id='all-css-0-2' href='https://s0.wp.com/wp-content/mu-plugins/highlander-comments/style.css?m=1530132353h&cssminify=yes' type='text/css' media='all' />
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="https://saicheems.wordpress.com/xmlrpc.php?rsd" />
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="https://s0.wp.com/wp-includes/wlwmanifest.xml" />
<meta name="generator" content="WordPress.com" />
<link rel='shortlink' href='https://wp.me/3JKq6' />
<link rel="stylesheet" href="css/style2.css">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-52447-2']);
_gaq.push(['_gat._anonymizeIp']);
_gaq.push(['_setDomainName', 'wordpress.com']);
_gaq.push(['_initData']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
})();
</script>
</head>
<article id="post-725" class="post-725 post type-post status-publish format-standard hentry category-uncategorized tag-3714698 tag-algorithm tag-egypt tag-input tag-online-judge tag-output tag-uva">
<header class="entry-header">
<h1 class="entry-title"><a href="https://codeforces.com/problemset/problem/1445/B" rel="bookmark"> 114B: Elimination</a></h1>
</header>
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<div class="entry-content">
<p><strong>Code:</strong></p><!-- Crayon Syntax Highlighter v_2.7.2_beta -->
<div id="crayon-5fb935331e03f900917834" class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
<div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><span class="crayon-title"></span>
<div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;"><div class="crayon-button crayon-nums-button" title="Toggle Line Numbers"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-plain-button" title="Toggle Plain Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-wrap-button" title="Toggle Line Wrap"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-expand-button" title="Expand Code"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-copy-button" title="Copy"><div class="crayon-button-icon"></div></div><div class="crayon-button crayon-popup-button" title="Open Code In New Window"><div class="crayon-button-icon"></div></div></div></div>
<div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;"></div>
<div class="crayon-plain-wrap"><textarea wrap="soft" class="crayon-plain print-no" data-settings="dblclick" readonly style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;">
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<pre class="brush: cpp; title: ; notranslate" title="">
#include <algorithm>
#include <cstdio>
using namespace std;
int main () {
int a, b, c;
for (;;) {
scanf("%d %d %d", &a, &b, &c);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == 0 && b == 0 && c == 0) break;
printf((a * a + b * b == c * c)? "right\n" : "wrong\n");
}
}
</pre>
<article id="post-725" class="post-725 post type-post status-publish format-standard hentry category-uncategorized tag-3714698 tag-algorithm tag-egypt tag-input tag-online-judge tag-output tag-uva">
<header class="entry-header">
<h1 class="entry-title"><a href="https://codeforces.com/problemset/problem/1445/B" rel="bookmark"> 112B: King's Path</a></h1>
</header>
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<pre class="brush: cpp; title: ; notranslate" title="">
#include <algorithm>
#include <cstdio>
using namespace std;
int main () {
int a, b, c;
for (;;) {
scanf("%d %d %d", &a, &b, &c);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == 0 && b == 0 && c == 0) break;
printf((a * a + b * b == c * c)? "right\n" : "wrong\n");
}
}
</pre>
<article id="post-725" class="post-725 post type-post status-publish format-standard hentry category-uncategorized tag-3714698 tag-algorithm tag-egypt tag-input tag-online-judge tag-output tag-uva">
<header class="entry-header">
<h1 class="entry-title"><a href="https://codeforces.com/problemset/problem/1445/B" rel="bookmark"> 11D: Jumping on Walls</a></h1>
</header>
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<pre class="brush: cpp; title: ; notranslate" title="">
#include <algorithm>
#include <cstdio>
using namespace std;
int main () {
int a, b, c;
for (;;) {
scanf("%d %d %d", &a, &b, &c);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == 0 && b == 0 && c == 0) break;
printf((a * a + b * b == c * c)? "right\n" : "wrong\n");
}
}
</pre>
<article id="post-725" class="post-725 post type-post status-publish format-standard hentry category-uncategorized tag-3714698 tag-algorithm tag-egypt tag-input tag-online-judge tag-output tag-uva">
<header class="entry-header">
<h1 class="entry-title"><a href="https://codeforces.com/problemset/problem/1445/B" rel="bookmark"> 221E: Serial Time</a></h1>
</header>
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<pre class="brush: cpp; title: ; notranslate" title="">
#include <algorithm>
#include <cstdio>
using namespace std;
int main () {
int a, b, c;
for (;;) {
scanf("%d %d %d", &a, &b, &c);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == 0 && b == 0 && c == 0) break;
printf((a * a + b * b == c * c)? "right\n" : "wrong\n");
}
}
</pre>
<article id="post-725" class="post-725 post type-post status-publish format-standard hentry category-uncategorized tag-3714698 tag-algorithm tag-egypt tag-input tag-online-judge tag-output tag-uva">
<header class="entry-header">
<h1 class="entry-title"><a href="https://codeforces.com/problemset/problem/1445/B" rel="bookmark"> 111A: One Horse</a></h1>
</header>
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<pre class="brush: cpp; title: ; notranslate" title="">
#include <algorithm>
#include <cstdio>
using namespace std;
int main () {
int a, b, c;
for (;;) {
scanf("%d %d %d", &a, &b, &c);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == 0 && b == 0 && c == 0) break;
printf((a * a + b * b == c * c)? "right\n" : "wrong\n");
}
}
</pre>
<article id="post-725" class="post-725 post type-post status-publish format-standard hentry category-uncategorized tag-3714698 tag-algorithm tag-egypt tag-input tag-online-judge tag-output tag-uva">
<header class="entry-header">
<h1 class="entry-title"><a href="https://codeforces.com/problemset/problem/1445/B" rel="bookmark"> 1211D: Party</a></h1>
</header>
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<pre class="brush: cpp; title: ; notranslate" title="">
#include <algorithm>
#include <cstdio>
using namespace std;
int main () {
int a, b, c;
for (;;) {
scanf("%d %d %d", &a, &b, &c);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == 0 && b == 0 && c == 0) break;
printf((a * a + b * b == c * c)? "right\n" : "wrong\n");
}
}
</pre>
<article id="post-725" class="post-725 post type-post status-publish format-standard hentry category-uncategorized tag-3714698 tag-algorithm tag-egypt tag-input tag-online-judge tag-output tag-uva">
<header class="entry-header">
<h1 class="entry-title"><a href="https://codeforces.com/problemset/problem/1445/B" rel="bookmark"> 1111: MAZE</a></h1>
</header>
<div class="entry-content">
<p>So I think this problem is very easy. All it’s asking you to do is compute Pythagorean theorem. Since the incoming values are < 30,000 we can just square the integers and check if the two sides of the equation (A^2 + B^2 = C^2) are equal. I did just that and submitted immediately. I got WA though so after looking at the problem again I realized there was no guaranteed ordering of the numbers. The equation I used relies on C being the largest of A and B. To rectify my algorithm I added some swap statements that ensure that C is the largest integer.</p>
<pre class="brush: cpp; title: ; notranslate" title="">
#include <algorithm>
#include <cstdio>
using namespace std;
int main () {
int a, b, c;
for (;;) {
scanf("%d %d %d", &a, &b, &c);
if (a > c) swap(a, c);
if (b > c) swap(b, c);
if (a == 0 && b == 0 && c == 0) break;
printf((a * a + b * b == c * c)? "right\n" : "wrong\n");
}
}
</pre>