3292:练47.4 小明吃苹果
练47.4 小明吃苹果
C代码:
/*
3292:练47.4 小明吃苹果
http://bas.ssoier.cn:8086/problem_show.php?pid=3292
*/
#include<stdio.h>
#include <stdlib.h>
#include <math.h>
int n;
int f(int x)
{
if( x==0 || x==1 )
{
return 1;
}
if( x==2 )
{
return 2;
}
if( x==3 )
{
return 2;
}
return f(x-2)+f(x-3);
}
int main( )
{
scanf("%d",&n);
printf("%d",f(n));
return 0;
}
C++程序:
#include <bits/stdc++.h>
using namespace std;
int n;
int f(int x){
if(x==0||x==1)return 1;
if(x==2)return 2;
if(x==3)return 2;
return f(x-2)+f(x-3);
}
int main(){
cin>>n;
cout<<f(n);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int n;
int f(int x){
if( x==0 || x==1 ){
return 1;
}
if( x==2 ){
return 2;
}
if( x==3 ){
return 2;
}
return f(x-2)+f(x-3);
}
int main( ){
cin>>n;
cout<<f(n);
return 0;
}
python3代码:
def f(x):
if x==0 or x==1:
return 1
if x==2:
return 2
if x==3:
return 2
return f(x-2)+f(x-3)
n=int(input())
print( f(n) )
CSP-J CSP-S 初赛模拟题
2021年CSP-S初赛模拟题
洛谷2020、2021、2022 CSP-J1 CSP-S1 第1轮 初赛模拟
洛谷2020、2021、2022、2023 CSP-J1 CSP-S1 第1轮 初赛模拟_2023cspj模拟题洛谷-CSDN博客
CSP-J CSP-S初赛第1轮模拟题(一)
CSP-J CSP-S初赛第1轮模拟题(二)
信奥中的数学:排列组合(小学四五年级)
信奥中的数学:排列组合
小学生微积分学习