问题 A: 木棒根数
解法:把所有的情况保存下来,加一下就好
#include<bits/stdc++.h> using namespace std; map<char,int>q; class P { public: int cmd(string s) { int sum=0; for(int i=0;i<s.length();i++) { sum+=q[s[i]]; } return sum; } }; int main() { string s; P solve; q['0']=6; q['1']=2; q['2']=5; q['3']=5; q['4']=4; q['5']=5; q['6']=6; q['7']=3; q['8']=7; q['9']=6; q['+']=2; q['-']=1; q['=']=2; cin>>s; cout<<solve.cmd(s)<<endl; return 0; }
问题 B: 一个苹果都不给我
解法:三种情况,单独买,套装买,和混合买
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main() { int n,m,p,q,ans[5]; cin>>n>>m>>p>>q; ans[0]=n*m; ans[1]=n/p*q+(n%p)*m; ans[2]=(n/p+1)*q; sort(ans,ans+3); cout<<ans[0]<<endl; return 0; }
问题 C: LED
解法:保存图形,然后xjb搞
include<stdio.h> #include<string.h> int main() { char num1[50]={" _ _ _ _ _ _ _ _ "}; char num2[50]={"| | | _| _||_||_ |_ ||_||_|"}; char num3[50]={"|_| ||_ _| | _||_| ||_| _|"}; char str,a[50]={"