From 1e8ddf39f7d66dd271d6b5c935399dc460adae52 Mon Sep 17 00:00:00 2001 From: sourcema Date: Sat, 23 Mar 2019 21:02:28 +0800 Subject: [PATCH] Create sourcema.md --- 2019.02.02-leetcode343/sourcema.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 2019.02.02-leetcode343/sourcema.md diff --git a/2019.02.02-leetcode343/sourcema.md b/2019.02.02-leetcode343/sourcema.md new file mode 100644 index 000000000..c33b3d6cb --- /dev/null +++ b/2019.02.02-leetcode343/sourcema.md @@ -0,0 +1,27 @@ +# leetcode 343 + class Solution { + public int integerBreak(int n) { + if(n==1){ + return n; + } + if(n==2){ + return 1; + } + if(n==3){ + return 2; + } + int num=n/3; + int res=n%3; + int ans=0; + if(res==0){ + ans=(int)Math.pow(3,num); + } + if(res==1){ + ans=(int)Math.pow(3,num-1)*4; + } + if(res==2){ + ans=(int)Math.pow(3,num)*2; + } + return ans; + } +}