Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
candies problem
#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; vector<int>a;cout<<"Enter candies and friend in sequence as qus(x,n):\n"; for(int i=0;i<2*n;i++) { int x; cin>>x; a.push_back(x); } //int i=0; cout<<"Nobita can return or ask to Mom for minimum candied are:\n"; for(int i=0;i<2*n;) { if(a[i]%a[i+1]>a[i+1]/2){cout<<a[i+1]-a[i]%a[i+1]<<endl;} else {cout<<a[i]%a[i+1]<<endl;} i= 2+i; } return 0; }
run
|
edit
|
history
|
help
1
Raw AVL
boost::shared_ptr<base>& arg
PreDir
march long ques 4
Dejalo a la Suerte
PriQHotel2
strcpy
Visakh
Policy based smart pointer
Base File.cpp