1 solutions
-
0
C :
#include <stdio.h> #include <math.h> int main () { int n,m; scanf("%d%d",&n,&m); long long num=pow(n,n+1)-(n-1)*m; printf("%lld",num); return 0; }
C++ :
#include<bits/stdc++.h> using namespace std; int main(){ int monkey,apple; long long int sum; cin>>monkey>>apple; sum=pow(monkey,monkey+1)-(monkey-1)*apple; cout<<sum<<endl; return 0; }
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); long ans=(long)Math.pow(n, n+1)-(n-1)*m; System.out.println(ans); } }
- 1
Information
- ID
- 10347
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By