2017年4月5日 星期三

UVa 12289 One-Two-Three - 參考答案

Difficulty: Eazy
Ref: UVa Online Judge - UVa 12289 One-Two-Three
/*******************************************************/
/* UVa 12289 - One-Two-Three                           */
/* Author: awei0905  [at]  awei0905.blogspot.tw        */
/* Version: 2017/04/04                                 */
/*******************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main() {
 int n, one;
 char input[6];
 scanf("%d", &n);
 while (n-- > 0 && scanf("%s", &input) != EOF) {
  if (input[3] != '\0') {
   printf("3\n");
   continue;
  }
  one = 0;
  if (input[0] == 'o') one++;
  if (input[1] == 'n') one++;
  if (input[2] == 'e') one++;
  if (one >= 2) printf("1\n");
  else  printf("2\n");
 }
}
Debug: I/O, uDebug
10
owe
too
theee
tne
owo
thfee
ono
twe
one
two
1
2
3
1
2
3
1
2
1
2

UVa 458 The Decoder - 參考答案

Difficulty: Eazy
Ref: UVa Online Judge - UVa 458 The Decoder
/*******************************************************/
/* UVa 458 - The Decoder                               */
/* Author: awei0905  [at]  awei0905.blogspot.tw        */
/* Version: 2017/04/04                                 */
/*******************************************************/
#define _CRT_SECURE_NO_WARNINIGS
#include <stdio.h>
#include <stdlib.h>

int main() {
 char a;
 while ((a = getchar()) != EOF)
  putchar(a == '\n' ? '\n' : a - 7);
}
Debug: I/O, uDebug
[opz'pz'h'x|p{l'zpunsl'wyvislt5
PM'`V\'HYL'YLHKPUN'[OPZ3'`V\'TH`IL'OH]L'MV\UK'[OL'ZVS\[PVU5
Rllw'jvkpun'huk'{yhpupun'{opz'rpuk'vm'wyvisltz5'P['JV\SK'IL'YLHSS`'L_JP[PUN5
Zv555
TH`'[OL'JVKL'IL'^P[O'`V\5
This is a quite single problem.
IF YOU ARE READING THIS, YOU MAYBE HAVE FOUND THE SOLUTION.
Keep coding and training this kind of problems. IT COULD BE REALLY EXCITING.
So...
MAY THE CODE BE WITH YOU.

UVa 272 TEX Quotes - 參考答案

Difficulty: Eazy
Ref: UVa Online Judge - UVa 272 TEX Quotes
/*******************************************************/
/* UVa 272 - TEX Quotes                                */
/* Author: awei0905  [at]  awei0905.blogspot.tw        */
/* Version: 2017/04/04                                 */
/*******************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main() {
 bool toggle = false;
 char a;
 while ((a = getchar()) != EOF)
  if (a == '"')
   printf((toggle = !toggle) ? "``" : "''");
  else putchar(a);
}
Debug: I/O, uDebug
Is branched in ""my up strictly "remember. "
Songs but chief has ham widow downs. Genius or so up vanity cannot. 
'''```Large do tried ``goi"'``''ng" about water defer by. "Silent" son man she wished mother. 
Distrusts allowance do knowledge eagerness assurance additions to. 
We """"diminution preference "thoroughly if. "Joy deal pain ';`392view" much her time. Led young gay would now state." 
Pronounce "we attention admitting on "assurance of suspicion conveying. That his west quit had met ""till"". Of advantage he 
attending "hous""ehold" at do perceived"." Middleton in objection "discovery" as agreeable. Edward thrown dining so he my around to. 
Is branched in ``''my up strictly ``remember. ''
Songs but chief has ham widow downs. Genius or so up vanity cannot. 
'''```Large do tried ``goi``'``''ng'' about water defer by. ``Silent'' son man she wished mother. 
Distrusts allowance do knowledge eagerness assurance additions to. 
We ``''``''diminution preference ``thoroughly if. ''Joy deal pain ';`392view`` much her time. Led young gay would now state.'' 
Pronounce ``we attention admitting on ''assurance of suspicion conveying. That his west quit had met ``''till``''. Of advantage he 
attending ``hous''``ehold'' at do perceived``.'' Middleton in objection ``discovery'' as agreeable. Edward thrown dining so he my around to. 

UVa 100 The 3n + 1 problem - 參考答案

Difficulty: Eazy
Ref: UVa Online Judge - UVa 100 The 3n + 1 problem
/*******************************************************/
/* UVa 100 - The 3n + 1 problem                        */
/* Author: awei0905  [at]  awei0905.blogspot.tw        */
/* Version: 2017/04/04                                 */
/*******************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int n3(int n) {
 if (n == 1) return 1;
 n = n % 2 ? 3 * n + 1 : n / 2;
 return n3(n) + 1;
}

int main() {
 int i, j;
 int mx, temp;
 while (scanf("%d%d", &i, &j) != EOF){
  printf("%d %d", i , j);
  if (i > j) {
   temp = i; i = j; j = temp;
  }
  mx = -1;
  for (int k = i; k <= j; k++) {
   if (mx < (temp = n3(k))) mx = temp;
  }
  printf(" %d\n", mx);
 }
}
Debug: I/O, uDebug
605293 606510
956739 956006                                    
826611 825983
756134 756776
478642 479101
815892 815933
719220 719135
929349 929040
605293 606510 341
956739 956006 352
826611 825983 313
756134 756776 362
478642 479101 338
815892 815933 269
719220 719135 274
929349 929040 339

2014年2月6日 星期四

[工具] - 10分鐘信箱

10分鐘信箱 - 為需要暫時信箱的使用者提供一個還不錯的解決方案。

簡單說,這信箱用一用就可以丟了,可以說是綠色 (環保) 信箱呢!

不需帳號、不需密碼、不需個人資料立即使用

因為用一用就能隨手拋棄,所以再也不用煩惱為何剛使用不久的 email 總是收到一堆垃圾信



2014年1月29日 星期三

[Arduino] [Visual Studio] - 使用 Visual Studio 取代 Arduino 原廠 IDE

最近上 CodePlex 看了看,找到了這功能強大的插件 「Arduino for Visual Studio and Atmel Studio」,它使我能擺脫以前難用的原廠 Arduino IDE ,且支援 Arduino 所有的板子、Serial Monitor、ISP、Bootloader‎,並將 Visual Studio 的特色融入其中,使在開發 Adruino 時也能兼具原本 Visial Studio 的撰寫環境,值得推薦!

Arduino for Visual Studio and Atmel Studio

下載位置:
CodePlex: http://visualmicro.codeplex.com/


安裝使用步驟:
當然,使用 Visual Studio 替代原廠 IDE 必須要有 Visual Studio 才能使用,我這邊使用的是 2012 版本。插件也要求使用者需安裝 Arduino 原廠的 IDE ,有支援 1.0.X 和 1.5.X,我這邊使用的是1.0.5版本。

1.下載並安裝程式檔案,下載連結在上方

2.啟動 Visual Studio ,並會看到多出了個似廣告的視窗,我們先不管它並繼續使用 free trail (試用版本)。選擇 free trail

3.選擇目前使用的 Arduino IDE 版本,並設定目前 Arduino IDE 的安裝路徑,另外 sketchbook 就看要不要填,我這邊是空著它。選擇 OK

4.如需新增一個 Arduino 專案,到 「檔案」->「新增」選擇「Sketch Project」後填入專案名稱並新增一個新的 Arduino 專案


以上安裝步驟概述完畢,但是寫完自己的程式總需要把程式燒錄至 Arduino ,對吧?
沒錯,不用想得太複雜,只需按下 F5 ,Arduino 專案會自己編譯後將程式燒錄至指定的 Serial Port。

*選擇 Arduino 板子類型,請在 Visual Studio 工具列上找到有 Arduino XXXX 的下拉式選單來選取
*選擇要燒錄的 Serial Port ,請在 Visual Studio 工具列上找到有 COMXX 的下拉式選單來選取
*使用 Serial Monitor,它就在選擇 Serial Port 下拉是選單的右方,點該按鈕即可叫出