2017年5月21日 星期日

ITSA 51 - [Problem 2] 數數之積 - 參考答案

Difficulty: Easy
Ref: IITSA 51 - [Problem 2] 數數之積
/*******************************************************/
/* [Problem 2] 數數之積                                 */
/* Author: awei0905  [at]  awei0905.blogspot.tw        */
/* Version: 2017/05/21                                 */
/*******************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main()
{
 char buf[40], *pch;
 while (fgets(buf, 40, stdin)) {
  unsigned long long ans = strtoull(buf, &pch, 10),temp;
  while (temp = strtoull(pch, &pch, 10))
   ans *= temp;
  printf("%llu\n", ans);
 }
 return 0;
}
Debug: I/O
一直乘。
2 7 9 40 2 
35 1 7 9 24 11
10080
582120

1 則留言: