Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
bharat
#include<bits/stdc++.h> using namespace std; #define ll unsigned long long int #define pb push_back #define mp make_pair #define vc vector #define fs first #define sec second #define pq priority_queue #define endl '\n' #define lb lower_bound #define ub upper_bound #define pll pair<ll,ll> #define pls pair<ll,string> #define psl pair<string,ll> #define plc pair<ll,char> #define pcl pair<char,ll> #define pss pair<string,string> const ll mod = 1000000007; #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) //map<int, int>::iterator itr; //count(arr, arr + n, 3); //count(vect.begin(), vect.end(), 3); //myvector.erase(iterator); iterator element k just baad wala ya fir index //myvector.erase(iterator1, iterator2); iterator elements baad and iterator2 element tak //*min_element(begin(A[A.size() - 1]), end(A[A.size() - 1])); min element in last row // STL: // (1) PRIORITY_QUEUE pq: // -> priority_queue < int > pq; // max_heap // -> priority_queue < int , vector < int > , greater < int > > pq; // min_heap // -> pq.top() --> returns the maximum or minimum element // -> pq.push() --> push element into the queue // -> pq.pop() --> remove top most element // -> pq.empty() --> checks whether queue is empty or not // (2) set / multiset ss; // --> ss.insert(key); (insertion) // --> ss.erase(ss.find(key)) .. (deletion) // --> ss.find(key) != ss.end() ..existence check // --> ss.lower_bound(x) -> smallest value which is greater than or equals to x // --> ss.upper_bound(x) --> first value strictly greater than x // --> multiset< data_type , greater<data_type> > ms; // for max ordering // (3) common functions // lower_bound(v.begin(),v.end(),x) - v.begin() --> smallest value greater than or equals to x // upper_bound(v.begin(), v.end(),x)- v.begin() --> smallest value greater than x // memset(dp , val , sizeof(dp)) -> sets the value of array dp to val //struct Node //{ // int data; // struct Node *left; // struct Node *right; // // Node(int x) // { // data=x; // left=NULL; // right=NULL: // } // //}; ll sun(ll n) { ll res=0; while(n>0) { res+=(n%10); n=n/10; } return res; } int main() { FastIO; ll t,n,s; cin >> t; while(t--) { cin >> n>>s; ll ans=0; if(sun(n)<=s) { cout<<0<<endl; } else { ll pw=1; for(int i=0;i<18;i++) { ll dig=(n/pw)%10; ll add=(pw*((10-dig)%10)); n+=add; ans+=add; if(sun(n)<=s) { break; } pw*=10; } cout<<ans<<endl; } } return 0; }
run
|
edit
|
history
|
help
0
zeroout
dodawanie "MIECIERZY"
Matrix multiplication naive approach
scanf error
Factorial Inv wip
Newspaper
palindrome
char pointer in class
Straight Max-Min
Eratosfen final