[原创]蓝桥杯 2016/3/17 测试 前6题题解…

2016-03-17 12:39:13 Tabris_ 阅读数：2585

https://blog.csdn.net/qq_33184171/article/details/50912690

## `12345678910111213141516171819202122232425262728293031323334353637``// tag==1 && *p!=' '# include <stdio.h># include <math.h># include <iostream>using namespace std;int get_word_num(char* buf){ int n=0; int tag=1; char* p=buf; for( ; *p!=0&&*p!=13&&*p!=10; p++) { if(*p==' ' && tag==0) tag=1; if( tag==1 && *p!=' ' ) { n++; tag=0; } } return n;}int main(){ char buf[1000]; fgets(buf,1000,stdin); printf("%d\n", get_word_num(buf)); return 0;}`2

1/1 + 1/2 + 1/3 + 1/4 + … 在数学上称为调和级数。

17126425374635

【数据格式】

5

1

100

2

3

0

CPU消耗 < 1000ms

005300000
800000020
070010500
400005300
010070006
003200080
060500009
004000030
000009700

145327698
839654127
672918543
496185372
218473956
753296481
367542819
984761235
521839764

800000000
003600000
070090200
050007000
000045700
000100030
001000068
008500010
090000400

812753649
943682175
675491283
154237896
369845721
287169534
521974368
438526917
796318452

CPU消耗 < 2000ms