摘要:这题一开始没看懂题,英文啊 ,不懂,后来一百度才知道是判断第n项fib能否被3整除;这题如果打表就会挂掉去,仔细分析fib各项可知每四项中有一项可以被3整除,而且是从0开始的第二项所以代码如下很水啊 !!!!!!!!!!!!!!!!!!!#include<stdio.h>int main( ){ int n; while( scanf( "%d",&n ) != EOF ) if( ( n + 2 ) % 4 == 0 ) puts( "yes" ); else puts( "no" ); return 0;}
阅读全文
摘要:JAVA水过import java.io.*;import java.util.*;import java.math.*;public class aa{ public static void main( String[]args ) { Scanner cin=new Scanner(System.in); int t; cin.hasNextInt(); t = cin.nextInt(); for( int i = 1; i <= t; ++i ) { BigInteger a,b,c; c = BigInteger.valueOf(0); b = c; while( cin.ha
阅读全文
摘要:JAVAimport java.io.*;import java.util.*;import java.math.BigInteger;import java.math.BigDecimal;;public class aa{ public static void main( String args[] ) { int a; Scanner in = new Scanner ( System.in ); //int t = in.nextInt(); while( in.hasNext() ) { a = in.nextInt(); BigInteger res = BigInteger.ON
阅读全文
摘要:java 水过import java.io.*;import java.util.*;import java.math.BigInteger;public class aa{ public static void main( String args[] ) { BigInteger a,b; Scanner in = new Scanner ( System.in ); int t = in.nextInt(); for( int i = 1; i <= t; ++i ) { in.hasNext(); a = in.nextBigInteger();b = in.nextBigInte
阅读全文
摘要:水题#include<stdio.h>int p[10001];void chart( ){ p[0] = 0; for( int i = 1; i <= 10010; ++i ) { int f = 1,sum = 0; for( int k = 1; k <= i / 2; ++k ) { if( i % k == 0 ) sum += k; if( sum > i ) break; } if( i == sum ) p[i] = p[i - 1] + 1; else p[i] = p[i - 1]; } }int main( ){ chart( ); int
阅读全文
摘要:i相信知道做前面那个后这个应该很水了#include<stdio.h>int m1[40000],m2[40000];void chart( ){ for( int i = 0 ; i <=32780; ++i ) { m1[i] = 1; m2[i] = 0; } for( int i = 2; i <= 3;++i ) { for( int j = 0; j <= 32780; ++j ) for( int k = 0; k + j <= 32780; k += i ) m2[j + k] += m1[j]; for( int j = 0; j <
阅读全文
摘要:这题是母函数的一模板题,如果你还不知道什么叫母函数,请去网上下载卢华明,卢开澄的<组合数学>,或者去tankywoo那里把原理看懂,http://www.wutianqi.com/?p=596。里面的第二章把母函数的原理分析得很透彻,下面讲代码实现.其实下面代码就是电脑模拟人工计算,而且很有规则,是从第一个括号开始算起,先把第一个括号跟第二个括号相乘,然后这两个括号就合并了,然后又把第一个括号跟第二个括号相乘,知道n个括号全部被算出来(i 就代表第几个括号正在被合并);我想大家肯定对m2[j + k] += m1[j]很疑惑,是的,我也在这卡了很久.我开始总以为这是什么公式,结果一
阅读全文
摘要:这题好悲剧啊,我用floyd做一直不能过,迷惑了我一晚上,改了N个地方还是wa,最后看着大牛代码改终于发现,floyd关系弄错了#include<stdio.h>int map[26][26];void floyd( ){ for( int i = 0; i < 26; ++i ) for( int j = 0 ; j < 26; ++j ) for( int k = 0; k < 26; ++k ) if( map[j][i] && map[i][k] ) map[j][k] = map[j][i] + map[i][k];//wa所在地 }vo
阅读全文
摘要:这题是以水题,开始被他唬了,后来听唐聪一说又是以单调,这个函数的倒数在0-100内事单调递增的,如果Y小于0,在0时导数值是大于0的,显然这是函数一直是递增的,所以最小值在0处产生,当Y大于0,求出X使得导数值等于0(二分),此时函数取得最小值,所以又是一水题啊 #include<iostream>#include<cmath>#include<cstdlib>using namespace std;double x,y,z;inline double fax( double x ){ return 6 * pow( x, 7 ) + 8 * pow( x,
阅读全文
摘要:这题开始差点把他做一元二次方程给解了,后面用到POW时才有感觉,后来想得好复杂,四元一次怎么解啊 ,最后好玩把0-100内所有的函数值全部打出来,竟发现左边的函数在0-100内是单调递增的,看到这儿各位该知道了吧,直接二分;还有判断循环要用函数值,不要用自变量,用自变量要精确到10的-6次方#include<stdio.h>#include<math.h>double x,y;double f( double x ){ return 8 * pow( x,4 ) + 7*x*x*x + 2*x*x + 3*x + 6;}int main( ){ int t; scanf
阅读全文
摘要:今天的这题有点悲剧,错就错在一个地方,在输入距离的时候,我把花费也考虑进去了,结果一只wa,没办法,看了大牛的代码才知道只要考虑距离;#include<stdio.h>int n,m,s,t;int inf = 0x7fffffff,des[1024],dis[1024],map[1024][1024];int co[1024],cost[1024][1024];void Dijkstra( ){ for( int i = 1; i <= n; ++i ) { dis[i] = co[i] = inf; des[i] = 0; } dis[s] = co[s] = 0; f
阅读全文
摘要:这题是字典树的以简单题但我开始一直不能水过,后来才发现rt用的不是自定义,再循环使用时没有初始化,后来将结构体自定义,果断水过,表示以后所有的结构体都用自定义#include<stdio.h>#include<stdlib.h>#include<string.h>const int max = 10;typedef struct T{ T *ch[max]; int f; }Trie;int flag = 1; char in[50];void init( T *t ){ t -> f = 0; for( int i = 0; i < max;
阅读全文
摘要:此题用字典树做,很快,据小白说还有一种方法:把每个单词的第一个字母存进去,然后再进行字符串比较,这样刚好不超时#include<stdio.h>#include<string.h>#include<stdlib.h>struct T{ T *ch[26]; int n;}rt;char in[30];void init( T *t ){ t -> n = 0; for( int i = 0; i < 26; ++i ) t -> ch[ i ] = NULL; }void insert( T *t,char *in ){ if( t -&g
阅读全文
摘要:这个地方要用string.h中的几个函数,特别是strcmp,可以比较两个时间;#include<stdio.h>#include<stdlib.h>#include<string.h>struct e{ char s1[20],s2[20],s3[20];}p[1000005];int main( ){ int t,n; scanf( "%d",&t ); while( t-- ) { scanf( "%d",&n ); for( int i = 0; i < n; ++i ) scanf( &
阅读全文
摘要:#include<stdio.h>#include<math.h>int main( ){ int x,y; while( scanf( "%d%d",&y,&x ) != EOF ) { int py ,px,min,t; min = t = 0; py = px = 0x7fffffff; for( int i = 1; i <= y; ++i ) { for( int j = 1; j <= x; ++j ) { scanf( "%d",&t ); if( fabs( t ) > f
阅读全文
摘要:#include<stdio.h>#include<string.h>int main( ){ char str[1024] = {0}; while( ( gets( str ) ) ) { int i = 0; while( str[i] ) { if( str[i] >= 'A' && str[i] <= 'Z' ) str[i] += 32; ++i; } printf( "%s\n",str ); memset( str,0,sizeof( str ) ); } return 0;
阅读全文
摘要:这题题意是,把数换成二进制,然后从右边数起第一个为1的位置n,然后最小数就是2*( n - 1 ),开始还想用短除法,不过小白说这里可以用A&-A,就可以得出来;#include<stdio.h>int main( ){ int x,y,z,n; while( scanf( "%d",&x ) ,n ) { z = 1; int y = 0; while( y != 1 ) { y = x % 2; x = x / 2; z *= 2; } printf( "%d\n",z / 2 ); } return 0;} #inclu
阅读全文
摘要:#include<stdio.h>int cal( int x,int y ){ return y ? cal( y , x % y ) : x;//求最大公约数}int main( ){ int x,y,z; while( scanf( "%d%d",&x,&y ) ) { z = x * y / cal ( x , y ); printf( "%d\n",z ); } return 0;}
阅读全文
摘要:#include<stdio.h>int map[1024][1024],des[1024],dis[1024],s,w;int m,n,inf = 0x7fffffff,q;int Dijkstra( ){ dis[0] = 0; for( int i = 0; i <= n; ++i ) { int min = inf,t = 0,pos = -1; for( int j = 0; j <= n; ++j ) { if( !des[j] ) if( dis[j] < min ) { min = dis[j]; pos = j; } } des[pos] = 1
阅读全文
摘要:#include<stdio.h>#include<stdlib.h>int m,n,map[1024][1024],des[1024],dis[1024],dep[1024];int inf = 0x7fffffff;int Dijkstra( int p ){ dis[p] = 0; for( int i = 1; i <= n; ++i ) { int min = inf, pos = 0,t; for( int j = 1; j <= n; ++j ) { if( !des[j] ) if( dis[j] < min ) { min = dis
阅读全文
摘要:#include<stdio.h>#include<math.h>#include<stdlib.h>struct E{ int x,y,set;}e[124];struct val{ int a,b; double dis;}va[10000];int t,c,count;int cmp( const void *a,const void *b ){ return ((val *)a)->dis > ((val *)b)->dis ? 1 : -1;}int find( int i ){ return e[i].set == i ? i
阅读全文
摘要:这题真恼火,写完代码后自己测试都能过,就是wa,于是我把代码重新敲了一遍,没想到还是wa,最后只能去找大牛的代码,大牛都是用字典树做的,显然与我的不符,最后在自己的代码上改,终于改到一个地方,在初始化的时候全部从0开始初始化,果断水过#include<stdio.h>#include<string.h>char word[160][300] = {0},a[300],b[300],start[300],end[300],p,q;int map[160][160],c,des[160],dis[160],n;int inf = 0x7fffffff;int obtain(
阅读全文
摘要:#include<stdio.h>int inf = 0x7fffffff;int map[1024][1024],des[1024],dis[1024],s,max,t,d,a[1024],b[1024];int Dijkstra( ){ ++max; for( int i = 1; i <= d; ++i ) map[b[i]][max] = map[max][b[i]] = 0; dis[0] = 0; for( int i = 0; i <= max; ++i ) { int min = inf,pos = -1,t; for( int j = 0; j <
阅读全文
摘要:#include<stdio.h>int inf = 0x7fffffff;int map[110][110],des[110],dis[110],n,m;//dis[i]表示i点到原点的距离void dij( )//des作为标记符{ dis[1] = 0; for( int i = 1; i <= n; ++i ) { int min = inf,pos = 0; for( int j = 1; j <= n; ++j )//找到当前未标记的权值最小的点 if( !des[j] && dis[j] < min ) { min = dis[ j
阅读全文
摘要:atof(将字符串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul表头文件 #include <stdlib.h>定义函数 double atof(const char *nptr);函数说明 atof()会扫描参数nptr字符串,跳过前面的空格字符,直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时('\0')才结束转换,并将结果返回。参数nptr字符串可包含正负号、小数点或E(e)来表示指数部分,如123.456或123e-2。返回值 返回转换后的浮点型数。附加说明 atof()与使用strtod(nptr
阅读全文
摘要:苹果的东西之所以如此贵,首先当然是品牌打得响,二是他的做工精细,漂亮,超薄,让人爱不释手,当然这些只是我们看到的表面原因,实际上还与它的背后有关,苹果的员工多数在美国,研发成本比较高。他们的工作条件在it企业数一数二,工资也很高,这都是苹果的东西很贵的主要原因。而且苹果的产品在全世界实行同价制度,但微软这样的企业把在中国发售的产品价格压低了一些,因为中国的消费水平不是太高。本观点取自百度知道
阅读全文
摘要:此题是最小生成树的基础题#include<stdio.h>#include<string.h>#include<stdlib.h>int set[124],n,t,a,b,c;long long min;struct map{ int x,y,val;}m[ 100000 ];int cmp( const void *a,const void *b ){ return ( ( map * ) a ) -> val - ( ( map * ) b ) -> val;}int find( int i ){ return set[ i ] == i ?
阅读全文
摘要:#include<stdio.h>#include<stdlib.h>#include<string.h>int len,map[26][ 26 ],des[26],a,b,f = 0,m;char ch[1000];void DFS( int n ){ if( f ) return ; if( n == 'm' - 'a' ) { f = 1; return; } for( int i = 0; i < 26 ; ++i ) { if( n != i && map[n][i] == 1 ) { if(
阅读全文
摘要:#include<stdio.h>#include<string.h>struct E{ char name[1000]; char less[1000]; int d; int num; }e[60024];int c = 0,max = 0,count = 0;void swap( int x,int y ){ struct E t; t = e[ x ]; e[ x ] = e[ y ]; e[ y ] = t; }int cmp( int x,int y ){ if( e[ x ].d == e[ y ].d ) if( e[x].num < e[y].n
阅读全文