HDU 1098 HDOJ 1098 Ignatius's puzzle ACM 1098 IN HDU

本文介绍了一道纯数学类型的编程题——HDU 1098的解题思路及代码实现,通过数学归纳法推导出判断条件,并提供了完整的C++代码。

 

MiYu原创, 转帖请注明 : 转载自 ______________白白の屋       

 

题目地址:

     http://acm.hdu.edu.cn/showproblem.php?pid=1098

题目分析:

     纯粹的数学题, 数学归纳法的 应用  , 最后 归纳得出  原题等价与 18 + k*a 是否能被65整除.

代码如下 :

ExpandedBlockStart.gif 代码
/*
Mail to   : miyubai@gamil.com
My Blog   : www.baiyun.me
Link      : 
http://www.cnblogs.com/MiYu   ||  http://www.cppblog.com/MiYu
Author By : MiYu
Test      : 1
Complier  : g++ mingw32-3.4.2
Program   : HDU_1098
Doc Name  : Ignatius's puzzle
*/
// #pragma warning( disable:4789 )
#include  < iostream >
#include 
< fstream >
#include 
< sstream >
#include 
< algorithm >
#include 
< string >
#include 
< set >
#include 
< map >
#include 
< utility >
#include 
< queue >
#include 
< stack >
#include 
< list >
#include 
< vector >
#include 
< cstdio >
#include 
< cstdlib >
#include 
< cstring >
#include 
< cmath >
#include 
< ctime >
using   namespace  std;
inline 
bool  scan_d( int   & num)
{
        
char   in ; bool  IsN = false ;
        
in = getchar();
        
if ( in == EOF)  return   false ;
        
while ( in != ' - ' && ( in < ' 0 ' || in > ' 9 ' ))  in = getchar();
        
if ( in == ' - ' ){ IsN = true ;num = 0 ;}
        
else  num = in - ' 0 ' ;
        
while ( in = getchar(), in >= ' 0 ' && in <= ' 9 ' ){
                num
*= 10 ,num += in - ' 0 ' ;
        }
        
if (IsN) num =- num;
        
return   true ;
}
int  main ()
{
    
int  N;
    
while  ( scan_d ( N ) ) {
        
if  ( N  %   65   ==   0  )
            puts ( 
" no "  );
        
else  {
            
int  i;
            
for  ( i  =   0 ; i  <   65 ++  i ) {
                
if  ( ( i  *  N  +   18  )  %   65   ==   0  ) {
                    printf ( 
" %d\n " , i );
                    
break ;
                }
            }
            
if  ( i  ==   65  ) puts (  " no "  );
        }
    }
    
return   0 ;
}

 

 

转载于:https://www.cnblogs.com/MiYu/archive/2010/10/28/1863882.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值