[Leetcode] 5279. Subtract the Product and Sum of Digits of an Integer

class Solution {
public int subtractProductAndSum(int n) {
int productResult = 1;
int sumResult = 0;
do {
int currentval = n % 10;
productResult *= currentval;
sumResult += currentval;
n /= 10;
}while(n > 0);
return productResult - sumResult;
}
}
[Leetcode] 5279. Subtract the Product and Sum of Digits of an Integer的更多相关文章
- 【leetcode】1281. Subtract the Product and Sum of Digits of an Integer
题目如下: Given an integer number n, return the difference between the product of its digits and the sum ...
- leetcode面试准备:Minimum Size Subarray Sum
leetcode面试准备:Minimum Size Subarray Sum 1 题目 Given an array of n positive integers and a positive int ...
- [Leetcode 40]组合数和II Combination Sum II
[题目] Given a collection of candidate numbers (candidates) and a target number (target), find all uni ...
- [Leetcode 39]组合数的和Combination Sum
[题目] Given a set of candidate numbers (candidates) (without duplicates) and a target number (target) ...
- Product and Sum in Category Theory
Even if you are not a functional programmer, the notion of product type should be familiar to you, e ...
- CodeForces 489C Given Length and Sum of Digits... (贪心)
Given Length and Sum of Digits... 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/F Descr ...
- Sum of Digits / Digital Root
Sum of Digits / Digital Root In this kata, you must create a digital root function. A digital root i ...
- Maximum Sum of Digits(CodeForces 1060B)
Description You are given a positive integer nn. Let S(x) be sum of digits in base 10 representation ...
- Codeforces Round #277.5 (Div. 2)C——Given Length and Sum of Digits...
C. Given Length and Sum of Digits... time limit per test 1 second memory limit per test 256 megabyte ...
随机推荐
- GraphQL快速入门教程
摘要: 体验神奇的GraphQL! 原文:GraphQL 入门详解 作者:MudOnTire Fundebug经授权转载,版权归原作者所有. GraphQL简介 定义 一种用于API调用的数据查询语言 ...
- bat弹出确认或取消窗口
需要在bat脚本里面弹出取消/确认框提示,可以用下面的案例: 示例: @echo off setlocal enabledelayedexpansion set Vbscript=Msgbox(&qu ...
- 对Quene中的队列的状态进行操作
查看队列的状态(包括队列的满状态.空.元素个数等等) import multiprocessing quene = multiprocessing.Queue(3) quene.put(12) que ...
- Shel脚本-初步入门之《01》
Shel脚本-初步入门-什么是 Shell 1.什么是 Shell Shell 是一个命令解释器,它的作用是解释执行用户输入的命令及程序等.Shell 存在于操作系统的最外层,负责与用户直接对话,把用 ...
- 07.进程管理+作业控制+文件查找与压缩+文件压缩与打包+tar打包解包+NFS
进程管理 程序放在磁盘上叫文件,把它复制到内存,并在cpu运行,就叫进程, 进程多少也反映当前运行程序的多少 进程在系统中会为每个进程生成一个进程号,在所有的进程中有一个特殊进程即init进程, 它是 ...
- 201871010101- 陈来弟《面向对象程序设计(java)》第6-7周学习总结
201871010101- 陈来弟<面向对象程序设计(java)>第6-7周学习总结 项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh ...
- 基于 webdriver 的测试代码日常调试方python 篇
看到论坛有人写了JAVA的测试代码日常设计,就给大家分享一下偶自己平时是如何测试测试代码的.主要基于python语言.基于 webdriver 的日常调试在 python交互模式下非常方便,打开pyt ...
- 【Spring AOP】切入点表达式(四)
一.切入点指示符 切入点指示符用来指示切入点表达式目的,在Spring AOP中目前只有执行方法这一个连接点,Spring AOP支持的AspectJ切入点指示符如下: execution:用于匹配方 ...
- Spring Cloud微服务安全实战_3-5_API安全之常见问题
1,数据校验,解决接口层的参数校验,是api安全的前线.可以用JSR303注解进行接口层面的校验 ,参考文章:https://www.ibm.com/developerworks/cn/java/j- ...
- IIS上传文件大小限制和上传时间限制
1.打开某一发布网站的配置编辑器 2.设置上传时间限制 3.设置上传文件大小限制 另一种方法: 直接在网站根目录建一个web.config文件 <?xml version="1.0&q ...