2013年7月11日 星期四

d086: 態度之重要的證明

http://zerojudge.tw/ShowProblem?problemid=d086

魔鬼測資:0123→Fail,而不是結束程式
所以檢查字串時還要確認是單純的"0"(結束程式),還是一個"0"開頭的字串(輸出 Fail)

 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
/**********************************************************************************/
/*  Problem: d086 "態度之重要的證明" from 成功電研20th~21st C++ ~最後的競賽~ */
/*  Language: CPP (650 Bytes)                                                     */
/*  Result: AC(4ms, 464KB) judge by this@ZeroJudge                                */
/*  Author: jrsh0906 at 2013-07-11 15:58:44                                       */
/**********************************************************************************/


/*
 Author: Hsu Shih Po
 Date: 11/07/13 15:41
 Description: d086: 態度之重要的證明
*/
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
 string proof;
 
 while(cin>>proof)
 {
  if(proof[0]=='0' && proof[1]=='\0')break;
  
  int sum = 0;
  
  for(int i = 0;i < proof.length();i++)
  {
   if(proof[i]>='A' && proof[i]<='Z')
    sum += proof[i] - 64;
   else if(proof[i]>='a' && proof[i]<='z')
    sum += proof[i] - 96;
   else
   {
    sum = -1;
    break;
   }
  }
  
  if(sum != -1)cout<<sum<<endl;
  else cout<<"Fail"<<endl;
 }
 
 return 0;
}

/*
A:65
a:97
Z:90
z:122
*/


2013年7月8日 星期一

d985: Gran Turismo 5

http://zerojudge.tw/ShowProblem?problemid=d985


 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
/**********************************************************************************/
/*  Problem: d985 "Gran Turismo 5" from 學姊                                    */
/*  Language: CPP (827 Bytes)                                                     */
/*  Result: AC(4ms, 404KB) judge by this@ZeroJudge                                */
/*  Author: jrsh0906 at 2013-07-09 13:50:17                                       */
/**********************************************************************************/


/*
 Author: Hsu Shih Po
 Date: 09/07/13 13:50
 Description: d985: Gran Turismo 5
*/
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
 int N = 0,M = 0;
 
 cin>>N;
 
 for(int a = 1;a <= N;a++)
 {
  cin>>M;
  
  int min = 0,sec = 0;
  
  cin>>min>>sec;
  
  int best_time = 0;
  
  best_time = min*60 + sec;
  
  int avg_time = best_time;
  
  for(int b = 1;b < M;b++)
  {
   cin>>min>>sec;
   
   int time = min*60 + sec;
   
   if(time < best_time)
    best_time = time;
    
   avg_time += time;  
  }
  
  avg_time /= M;
  
  cout<<"Track "<<a<<":"<<endl;
  cout<<"Best Lap: "<<best_time/60<<" minute(s) "<<best_time%60<<" second(s).\n";
  cout<<"Average: "<<avg_time/60<<" minute(s) "<<avg_time%60<<" second(s).\n";
  cout<<endl;
 }
 
 return 0;
}