1 条题解
-
0
C :
#include<stdio.h> void main() { int a,b,c,i=0; for(a=1;a<100;a++){ for(b=1;b<(100-a)/2;b++){ c=(100-a-2*b)/5; if(a+2*b+5*c==100) i++; } } printf("%d",i); }C++ :
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main(){ int a,b,c,s=0; for(a=1;a<=1*100/5;a++){ for(b=1;b<=1*100/2;b++){ for(c=1;c<=1*100/1;c++){ if(a*5+b*2+c*1==1*100){ s=s+1; } } } }cout<<s<<endl; }Pascal :
var i,n,s,a,b,c,d:longint; begin for a:=1 to 93 do for b:=1 to 47 do for c:=1 to 19 do begin if a*1+b*2+c*5=100 then s:=s+1; end; write(s); end.Java :
public class Main{ public static void main(String[] args) { int n=0; for(int i=1;i<=100;i++){ for(int j=1;j<=50;j++){ for(int k=1;k<=20;k++){ if(i+2*j+5*k==100){ n++; } } } } System.out.println(n); } }Python :
b = 0 for i in range (1, 100): for m in range (1, 50): for n in range (1, 20): if i * 1 + 2 * m + n * 5 == 100 and i != 0 and m != 0 and n != 0: b += 1 print(b)
- 1
信息
- ID
- 24
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 10
- 标签
- 递交数
- 3
- 已通过
- 1
- 上传者