首页 > TAG信息列表 > 1281

1281. Subtract the Product and Sum of Digits of an Integer

!!!题目地址!!! int subtractProductAndSum(int n){ int product = 1; int sum = 0; while(n != 0){ product *= n%10; sum += n%10; n /= 10; } return product-sum; }

为什么学习?

你累了吗? 我们会觉得身上的压力无穷尽,喘不过气,叫不出声,又使不上劲! 也许无论你怎么努力,都达不到你想要的结果! 你有可以选择的机会吗? 你是被迫谋生吗? 没了你的父母你还能干些什么?  你有钱对你来说只是数字的概念吗? 别说我满足现在的生活,当你遇见疾病,遇见现实,说着我喜欢的人在别人

1281:最长上升子序列

最长上升子序列 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 const int N=1005; 5 6 int a[N],f[N]; 7 int main(){ 8 int n,maxx=0; 9 cin>>n; 10 for(int i=1;i<=n;i++) 11 scanf("%d",&

1281: [蓝桥杯2015决赛]奇怪的数列 【中 / 字符串】

http://oj.ecustacm.cn/problem.php?id=1281 #include<cstring> #include<string> #include<cstdio> #include<iostream> using namespace std; int main(void) { string a; int n; cin>>a>>n; for(int i=1;i<=n;i++) { strin

1281. 整数的各位积和之差

给你一个整数 n,请你帮忙计算并返回该整数「各位数字之积」与「各位数字之和」的差。   示例 1: 输入:n = 234 输出:15 解释:各位数之积 = 2 * 3 * 4 = 24 各位数之和 = 2 + 3 + 4 = 9 结果 = 24 - 9 = 15示例 2: 输入:n = 4421输出:21解释: 各位数之积 = 4 * 4 * 2 * 1 = 32 各位数之和

1281. 整数的各位积和之差

di地址:https://leetcode-cn.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/ <?php /** 给你一个整数 n,请你帮忙计算并返回该整数「各位数字之积」与「各位数字之和」的差。   示例 1: 输入:n = 234 输出:15 解释: 各位数之积 = 2 * 3 * 4 = 24 各位数之

1281. Subtract the Product and Sum of Digits of an Integer

class Solution { public: int subtractProductAndSum(int n) { int sum=0; int multiple=1; while(n!=0){ sum += n%10; multiple *= n%10; n = n/10; } //cout<<sum<<endl;