当前位置:网站首页>1317. convert an integer to the sum of two zero free integers
1317. convert an integer to the sum of two zero free integers
2022-06-27 05:55:00 【Mr Gao】
1317. Convert an integer to the sum of two nonzero integers
「 Zero free integer 」 Is in the decimal representation It doesn't contain any 0 The positive integer .
Give you an integer n, Please return one A list of two integers [A, B], Satisfy :
A and B Are zero free integers
A + B = n
The problem data ensures that there is at least one effective solution .
If there are multiple effective solutions , You can return any of them .
Example 1:
Input :n = 2
Output :[1,1]
explain :A = 1, B = 1. A + B = n also A and B The decimal representation of does not contain any 0 .
Example 2:
Input :n = 11
Output :[2,9]
Example 3:
Input :n = 10000
Output :[1,9999]
Example 4:
Input :n = 69
Output :[1,68]
Example 5:
Input :n = 1010
Output :[11,999]
This question is comparatively simple , The solution code is as follows :
/** * Note: The returned array must be malloced, assume caller calls free(). */
bool f(int n){
while(n){
if(n%10==0){
return false;
}
n=n/10;
}
return true;
}
int* getNoZeroIntegers(int n, int* returnSize){
int *re=(int *)malloc(sizeof(int)*2);
int i;
for(i=1;i<n;i++){
if(f(n-i)&&f(i)){
re[0]=i;
re[1]=n-i;
*(returnSize)=2;
return re;
}
}
return re;
}
边栏推荐
- 函数式 连续式
- 双位置继电器JDP-1440/DC110V
- 洛谷P2939 [USACO09FEB]Revamping Trails G 题解
- Codeforces Round #802 (Div. 2)
- 【FPGA】 基于FPGA分频,倍频设计实现
- 【QT小作】使用结构体数据生成读写配置文件代码
- Free SSH and telnet client putty
- IAR systems fully supports Centrino technology 9 series chips
- [FPGA] realize the data output of checkerboard horizontal and vertical gray scale diagram based on bt1120 timing design
- Openresty usage document
猜你喜欢

【FPGA】 基于FPGA分频,倍频设计实现

Discussion on streaming media protocol (MPEG2-TS, RTSP, RTP, RTCP, SDP, RTMP, HLS, HDS, HSS, mpeg-dash)

Go log -uber open source library zap use

Assembly language - Wang Shuang Chapter 13 int instruction - Notes

cpu-z中如何查看内存的频率和内存插槽的个数?

How win 10 opens the environment variables window

EasyExcel合并相同内容单元格及动态标题功能的实现

汇编语言-王爽 第11章 标志寄存器-笔记

Two position relay xjls-8g/220

Double position relay jdp-1440/dc110v
随机推荐
Acwing's 57th weekly match -- BC question is very good
openresty使用文档
How JQ gets the ID name of an element
Unity中跨平台获取系统音量
【FPGA】基于bt1120时序设计实现棋盘格横纵向灰阶图数据输出
思维的技术:如何破解工作生活中的两难冲突?
C语言实现定时器
微信小程序刷新当前页面
网易云音乐params和encSecKey参数生成代码
Software testing year end summary report template
Ad22 Gerber files Click to open the Gerber step interface. Official solutions to problems
我对于测试团队建设的意见
C language implementation timer
KubeSphere 集群配置 NFS 存储解决方案-收藏版
【养成系】常用正则表达式
【Cocos Creator 3.5.1】event.getButton()的使用
Reading graph augmentations to learn graph representations (lg2ar)
汇编语言-王爽 第11章 标志寄存器-笔记
Code is data
Codeforces Round #802 (Div. 2)