Sfoglia il codice sorgente

上传文件至 ''

meng 5 anni fa
parent
commit
1b2eec7248
3 ha cambiato i file con 81 aggiunte e 0 eliminazioni
  1. 19 0
      E.cpp
  2. 34 0
      F.cpp
  3. 28 0
      G.cpp

+ 19 - 0
E.cpp

@@ -0,0 +1,19 @@
+#include<bits/stdc++.h>
+using namespace std;
+int main()
+{
+    int a,b,c;
+    while(cin>>a>>b){
+        if(a==0&&b==0){
+            break;
+        }
+        else{
+            c=(a+b)%7;
+        }
+        if(c==0){
+            c+=7;
+        }
+        cout<<c<<endl;
+    }
+    return 0;
+}

+ 34 - 0
F.cpp

@@ -0,0 +1,34 @@
+#include<bits/stdc++.h>
+#define PI 3.1415926
+#define ll long long
+#define foto(i,l,r) for(ll i=l;i<r;i++)
+using namespace std;
+ll v[25][25][25]={0};
+ll w(ll a,ll b,ll c){
+    if(a<=0||b<=0||c<=0){return 1;}
+    else if(v[a][b][c]!=0) return v[a][b][c];
+    else if(a>20||b>20||c>20) v[a][b][c]=w(20,20,20);
+    else if(a<b&&b<c){
+         v[a][b][c]=w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c);
+    }
+    else{
+    v[a][b][c]=w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1);
+    }
+    return v[a][b][c];
+}
+
+int main()
+{
+    ll a,b,c;
+    while(cin>>a>>b>>c){
+        memset(v,0,sizeof(v));
+        if(a==-1&&b==-1&&c==-1){
+            return 0;
+        }
+        printf("w(%lld, %lld, %lld) = ",a,b,c);
+                if(a>20) a=21;
+                if(b>20) b=21;
+                if(c>20) c=21;
+                printf("%lld\n",w(a,b,c));
+    }
+}

+ 28 - 0
G.cpp

@@ -0,0 +1,28 @@
+#include<bits/stdc++.h>
+using namespace std;
+bool cmp(string &a,string &b){
+    return a > b;
+}
+int main()
+{
+    string s;
+    int n;
+    cin>>n;
+    while(n--){
+        cin>>s;
+        if(s.size()-1==0){
+            cout<<0<<endl;
+            continue;
+        }else{
+            vector<string> v;
+            int l=s.size();
+            for(int i=0;i<l;i++){
+                string t=s;
+                t.erase(t.begin()+i);
+                v.push_back(t);
+            }
+            sort(v.begin(),v.end(),cmp);
+            cout<<v[l-1]<<endl;
+        }
+    }
+}