信奥中的数学 数论 第1讲 整除的概念与基本性质

1、1.4编程基础之逻辑表达式与条件分支 08 判断一个数能否同时被3和5整除

OpenJudge - 08:判断一个数能否同时被3和5整除

/*
1.4编程基础之逻辑表达式与条件分支 08 判断一个数能否同时被3和5整除
http://noi.openjudge.cn/ch0104/08/
*/
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	
	if( n%3 == 0 && n%5 == 0 ) 
	{
		cout<<"YES";
	}
	else
	{
		cout<<"NO";
	}
	return 0;
}

2、1.4编程基础之逻辑表达式与条件分支 09 判断能否被3,5,7整除

OpenJudge - 09:判断能否被3,5,7整除

 

/*
1.4编程基础之逻辑表达式与条件分支 09 判断能否被3,5,7整除
http://noi.openjudge.cn/ch0104/09/
*/
#include <bits/stdc++.h>  //通用头文件
using namespace std;  //名字空间 
int main()
{
	int x;
	
	cin>>x;
	
	if(x%3==0)
	{
		cout<<"3"<<" ";
		
	}
	
	if(x%5==0)
	{
		cout<<"5"<<" ";
	}
		
	if(x%7==0)
	{
		cout<<"7"<<" ";
	}
	
	if(x%3!=0 && x%5!=0 && x%7!=0)
	{
		cout<<"n"<<endl;
	}
	
	return 0;	
} 

3、在100以内同时被2 3 5整除的正整数有多少个?

/*
1、在 100 以内同时被 2 3 5 整除的正整数有多少个?
*/
#include <bits/stdc++.h>
using namespace std;
int main( void )
{
	int ans=0;
	
	for(int i=1;i<=100;i++)
	{
		if( i%2==0 && i%3==0 && i%5==0 )
		{
			cout<<i<<endl;
			ans+=1;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

/*
1、在 100 以内同时被 2 3 5 整除的正整数有多少个?
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
    int cnt=0;
    for(int i=1;i<=100;i++){
        if(i%30==0){
            cnt++;
        }
    }
    cout<<cnt;
	return 0;
}

 4、求1000以内同时被3 4 5 6整除的正整数的个数

/*
2、求 1000 以内同时被 3 4 5 6 整除的正整数的个数
*/
#include <bits/stdc++.h>
using namespace std;
int main( void )
{
	int ans=0;
	
	for(int i=1;i<=1000;i++)
	{
		if( i%3==0 && i%4==0 && i%5==0 && i%6==0 )
		{
			cout<<i<<endl;
			ans+=1;
		}
	}
	
	cout<<ans<<endl;
	
	return 0;
}

5、设五位数x679y被72整除,求数字x与y 

/*
3、设五位数 x679y 被 72 整除,求数字 x 与 y
*/
#include <bits/stdc++.h>
using namespace std;
int main( void )
{
	int x,y,ans=0;
	
	for(int i=0;i<=9;i++)
	for(int j=1;j<=9;j++)
	{
		if( (790+i)%8==0  && (j+6+7+9+i)%9==0 )
		{
			y=i;
			x=j;
			
			cout<<"x="<<x<<" y="<<y<<endl;
		}
	}	
	
	return 0;
}
#include<bits/stdc++.h>
using namespace std;
int main()
{
	for(int i=1;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
		{
			if((i*10000+6790+j)%72==0)
			{
				cout<<i<<' '<<j;
				//return 0;
			}
		}
	}
	return 0;
}

6、N=19991999...1999(1999 个 1999),求 N 被 11 除以所得到的余数 

/*
4、N=19991999...1999(1999 个 1999),求 N 被 11 除以所得到的余数
*/
#include <bits/stdc++.h>
using namespace std;
int main( void )
{
	int ans=0;
	
	ans=1999*(9+9-9-1)%11;
	
	cout<<ans<<endl;
	
	return 0;
}
/*
4、N=19991999...1999(1999 个 1999),求 N 被 11 除以所得到的余数
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	
	a=(8*1999)%11;
	
	cout<<a;
	
	return 0;
}

7、证明:abcabc 6 位数 一定能被 7 11 13 整除 

/*
8、证明:abcabc 6 位数 一定能被 7 11 13 整除
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t=1,an;
	for(int a=1;a<=9;a++)
		for(int b=0;b<=9;b++)
			for(int c=0;c<=9;c++)
			{
				an=(a*100000+
					b*10000+
					 c*1000+
					  a*100+
					   b*10+
						c);
				if(an%7!=0&&an%11!=0&&an%13!=0)
					t=0;
			}
	cout<<t;
	return 0;
}

/*
8、证明:abcabc 6 位数 一定能被 7 11 13 整除
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int t=1,an,cnt=0;
	for(int a=1;a<=9;a++)
		for(int b=0;b<=9;b++)
			for(int c=0;c<=9;c++)
			{
				an=(a*100000+
					b*10000+
					 c*1000+
					  a*100+
					   b*10+
						c);
				cnt+=1;
				
				if( cnt%30==0)
				{
					cout<<endl;
				}
				if( an%7==0 && an%11==0 && an%13==0)
					cout<<"Yes ";
				else
				{
					cout<<"No "<<endl;
				}
			}
			
	return 0;
}
/*
8、证明:abcabc 6 位数 一定能被 7 11 13 整除
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	for(long long i=1;i<=9;i++) 
	{
		for(long long j=0;j<=9;j++) 
		{
			for(long long k=0;k<=9;k++) 
			{
				int tmp=i*100000+i*100+j*10000+j*10+k*1000+k*1;
				if( i==1 && tmp%7==0 && tmp%11==0 && tmp%13==0 )
				{
					cout<<tmp<<endl; 
				}
			}
		}
	}

	return 0;
}
/*
100100
101101
102102
103103
104104
105105
106106
107107
108108
109109
110110
111111
112112
113113
114114
115115
116116
117117
118118
119119
120120
121121
122122
123123
124124
125125
126126
127127
128128
129129
130130
131131
132132
133133
134134
135135
136136
137137
138138
139139
140140
141141
142142
143143
144144
145145
146146
147147
148148
149149
150150
151151
152152
153153
154154
155155
156156
157157
158158
159159
160160
161161
162162
163163
164164
165165
166166
167167
168168
169169
170170
171171
172172
173173
174174
175175
176176
177177
178178
179179
180180
181181
182182
183183
184184
185185
186186
187187
188188
189189
190190
191191
192192
193193
194194
195195
196196
197197
198198
199199

--------------------------------
Process exited after 0.5736 seconds with return value 0
请按任意键继续. . .
704704
705705
706706
707707
708708
709709
710710
711711
712712
713713
714714
715715
716716
717717
718718
719719
720720
721721
722722
723723
724724
725725
726726
727727
728728
729729
730730
731731
732732
733733
734734
735735
736736
737737
738738
739739
740740
741741
742742
743743
744744
745745
746746
747747
748748
749749
750750
751751
752752
753753
754754
755755
756756
757757
758758
759759
760760
761761
762762
763763
764764
765765
766766
767767
768768
769769
770770
771771
772772
773773
774774
775775
776776
777777
778778
779779
780780
781781
782782
783783
784784
785785
786786
787787
788788
789789
790790
791791
792792
793793
794794
795795
796796
797797
798798
799799
800800
801801
802802
803803
804804
805805
806806
807807
808808
809809
810810
811811
812812
813813
814814
815815
816816
817817
818818
819819
820820
821821
822822
823823
824824
825825
826826
827827
828828
829829
830830
831831
832832
833833
834834
835835
836836
837837
838838
839839
840840
841841
842842
843843
844844
845845
846846
847847
848848
849849
850850
851851
852852
853853
854854
855855
856856
857857
858858
859859
860860
861861
862862
863863
864864
865865
866866
867867
868868
869869
870870
871871
872872
873873
874874
875875
876876
877877
878878
879879
880880
881881
882882
883883
884884
885885
886886
887887
888888
889889
890890
891891
892892
893893
894894
895895
896896
897897
898898
899899
900900
901901
902902
903903
904904
905905
906906
907907
908908
909909
910910
911911
912912
913913
914914
915915
916916
917917
918918
919919
920920
921921
922922
923923
924924
925925
926926
927927
928928
929929
930930
931931
932932
933933
934934
935935
936936
937937
938938
939939
940940
941941
942942
943943
944944
945945
946946
947947
948948
949949
950950
951951
952952
953953
954954
955955
956956
957957
958958
959959
960960
961961
962962
963963
964964
965965
966966
967967
968968
969969
970970
971971
972972
973973
974974
975975
976976
977977
978978
979979
980980
981981
982982
983983
984984
985985
986986
987987
988988
989989
990990
991991
992992
993993
994994
995995
996996
997997
998998
999999

--------------------------------
Process exited after 1.667 seconds with return value 0
请按任意键继续. . .
*/

8、求一个4位数,使它等于抹去它的首位数之后剩下的三位数字与3的乘积减去42所得的差

/*
9、求一个 4 位数,使它等于抹去它的首位数之后剩下
的三位数字与 3 的乘积减去 42 所得的差
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int ans,x;
	for(int a=1;a<=9;a++)
		for(int b=0;b<=9;b++)
			for(int c=0;c<=9;c++)
			for(int d=0;d<=9;d++)
			{
				ans=b*100+c*10+d;
				x= ans*3-42;
				if( x==a*1000+b*100+c*10+d )
					cout<<x<<endl;
			}
	return 0;
}
/*
9、求一个 4 位数,使它等于抹去它的首位数之后剩下
的三位数字与 3 的乘积减去 42 所得的差
*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	for(int i=1000;i<=9999;i++)
	{
		int ans=i,num=0;
		
		while( ans>=10 )
		{
			ans=ans/10;
		}
		
		ans*=1000;
		num+=i%10;
		num+=(i/10%10)*10;
		num+=(i/100%10)*100;
		
		if( ans+num==num*3-42 )
		{
			cout<<i<<endl;
		}
	}

	return 0;
}


 9、小学奥数 7657 连乘积末尾0的个数

OpenJudge - 7657:连乘积末尾0的个数

*/
#include <cstdio>
#define min(a, b) (a < b ? a : b)

inline int five(int a)
{
	int res = 0;
	while (a % 5 == 0)
	{
		a /= 5;
		res++;
	}
	return res;
}

inline int two(int a)
{
	int res = 0;
	while (a % 2 == 0)
	{
		a /= 2;
		res++;
	}
	return res;
}

int main()
{
	int a, b, m = 0, n = 0;
	scanf("%d%d", &a, &b);
	
	for (int i = a; i <= b; i++)
	{
		m += two(i);
		n += five(i);
	}
	printf("%d", min(m, n));
	return 0;
}

10、小学奥数 7826 分苹果

OpenJudge - 7826:分苹果

/*
小学奥数 7826 分苹果
http://noi.openjudge.cn/math/7826/
*/
#include <iostream>
 
using namespace std;
 
int main()
{
    int n;
 
    cin >> n;
 
    cout << n * (n + 1) / 2 << endl;
 
    return 0;
}

 


   

1、《奥数教程 七年级》 单墫

2、《数学女王的邀请 初等数论入门》 远山启著 逸宁 译

3、《整除、同余与不定方程》 冯志刚

4、《初中数学竞赛专家讲座 初等数论》

5、《数学选修4-6 初等数论初步》

6、《程序员的数学思维修炼》 周颖

7、《程序员的数学》 结诚浩 著 管杰 译

8、《小学生C++编程入门》 喻蓉蓉

9、《信息学奥赛一本通 初赛真题解析》(2022.06)

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dllglvzhenfeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值