题解

MESSI  •  2年前


include <bits/stdc++.h>

using namespace std; string s1,s2; int a[250000],b[250000],c[500000]; int i,j,p; int main(){

cin>>s1>>s2;
for(i = 0;i < s1.size();i++){
	a[i] = s1[s1.size() - i - 1] - '0';
} 

for(i = 0;i < s2.size();i++){
	b[i] = s2[s2.size() - i - 1] - '0';
} 
for(i = 0;i < s1.size();i++){
	for(j = 0;j < s2.size();j++){
		c[i+j] = c[i+j] + a[i] * b[j];
		if(c[i+j] >= 10){
			c[i+j+1] = c[i+j+1] + c[i+j] / 10;
			c[i+j] = c[i+j] % 10;
		} 
	}
} 
for(i = s1.size() + s2.size() - 1;i >= 0;i--){
	if(c[i] != 0){
		p = i;
		break;
	}
} 
for(i = p;i >= 0;i--){
	cout<<c[i];
}

}


评论:

include <bits/stdc++.h>

using namespace std;

int a[4] = {20, 10, 5, 1}, sum = 0, num = 0, i = 0, n, f[100000001];

int main()

{

//freopen("coin.in","r",stdin);freopen("coin.out","w",stdout);

memset(f, -1, sizeof(f));

cin >> n;

f[0] = 0;

for (i = 0; i < 4 && f[n] == -1; ++i)

	for (int j = a[i]; j <= n; j += a[i])

		if (f[j] == -1)
			f[j] = f[j - a[i]] + 1;

cout << f[n] << " " << i;

//fclose(stdin);fclose(stdout);

return 0;

}


刘宸志 CEUA  •  2年前

include

include

using namespace std; char a[13]; int b[9]; int i, j, s = 0, l = 0;

int main() {

cin >> a;
for (i = 0; i < 11; i++) {
	if (a[i] != '-') {
		l++;
		s += (a[i] - '0') * l;
	}
}
s = s % 11;
if (s == 10) {
	if (a[12] == 'X') {
		cout << "Right";
	} else {
		a[12] = 'X';
		cout << a;
	}
} else {
	if (a[12] - '0' == s) {
		cout << "Right";
	} else {

		a[12] = char (s + 48);;
		cout << a;
	}
}

return 0;

}


刘宸志 CEUA  •  2年前

请先登录,才能进行评论