File tree Expand file tree Collapse file tree 3 files changed +114
-0
lines changed
Expand file tree Collapse file tree 3 files changed +114
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ int main (){
5+
6+ int t;
7+ cin >> t;
8+
9+ while (t--){
10+ int d;
11+ cin >> d;
12+
13+ int arr[32 ]={0 };
14+
15+ for (int i=0 ;i<d;i++){
16+ int di,pi;
17+ cin >> di >> pi;
18+
19+ arr[di]+=pi;
20+ }
21+
22+ for (int i=1 ;i<=31 ;i++){
23+ arr[i]+=arr[i-1 ];
24+ }
25+
26+ int q;
27+ cin >> q;
28+
29+ for (int i=0 ;i<q;i++){
30+ int di,ri;
31+ cin >> di >> ri;
32+
33+ if (arr[di]<ri)
34+ cout << " Go Sleep" << endl;
35+ else
36+ cout << " Go Camp" << endl;
37+ }
38+
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+ using namespace std ;
3+
4+ #define ll long long
5+ #define MOD 1000000007
6+ #define f (i,a,b ) for (int i=a;i<b;i++)
7+
8+ int main (){
9+ int t;
10+ cin >> t;
11+
12+ while (t--){
13+ string s;
14+ cin >> s;
15+
16+ int l=s.length ();
17+ ll mi=0 ,total;
18+
19+ vector<ll>arr (100005 );
20+
21+ arr[0 ]=1 ;
22+
23+ f (i,1 ,100005 ){
24+ arr[i]=(arr[i-1 ]*10 )%MOD;
25+ }
26+
27+ f (i,0 ,l){
28+ mi+=((s[i]-' 0' )*arr[l-i-1 ])%MOD;
29+ }
30+ mi = mi%MOD;
31+ // cout << mi << endl;
32+ total=mi;
33+
34+ f (i,0 ,s.length ()-1 ){
35+ mi=(((mi*10 )%MOD+(s[i]-' 0' ))%MOD-((s[i]-' 0' )*arr[l])%MOD)%MOD;
36+ if (mi<0 )
37+ mi+=MOD;
38+ total=((total*arr[l])%MOD+mi)%MOD;
39+
40+
41+ }
42+
43+ total%=MOD;
44+ cout << total << endl;
45+
46+
47+ }
48+ }
Original file line number Diff line number Diff line change 1+ /* *
2+ * Definition for a binary tree node.
3+ * struct TreeNode {
4+ * int val;
5+ * TreeNode *left;
6+ * TreeNode *right;
7+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8+ * };
9+ */
10+ class Solution {
11+ public:
12+ TreeNode* insertIntoBST (TreeNode* root, int val) {
13+ if (!root){
14+ TreeNode* n = new TreeNode (val);
15+ return n;
16+ }
17+
18+
19+ if (root->val > val)
20+ root->left =insertIntoBST (root->left ,val);
21+ else
22+ root->right =insertIntoBST (root->right ,val);
23+
24+ return root;
25+ }
26+ };
You can’t perform that action at this time.
0 commit comments