- #include <bits/stdc++.h>
- using namespace std;
- int mod = 1000000007, n;
- vector <int> dp;
- vector <int> coin;
- vector <int> visited;
- int aa(int x)
- {
- if(visited[x]) return dp[x];
- for(int i=0; i<n; i++)
- {
- if(coin[i]<=x)
- {
- dp[x] += aa(x-coin[i]);
- dp[x]%=mod;
- }
- }
- //cout << x << " " << dp[x] << endl;
- visited[x]++;
- return dp[x];
- }
- void sswap(int *, int *);
- int main()
- {
- /*
- int x;
- cin >> n >> x;
- dp.resize(x);
- visited.resize(x);
- coin.resize(n);
- dp[0]++;
- visited[0]++;
- for(int i=0; i<n; i++)
- cin >> coin[i];
- cout << aa(x);
- return 0;
- */
- int x = 1, y = 2;
- cout<<"[對調前]"<<endl;
- cout<<"x="<<x<<endl;
- cout<<"y="<<y<<endl;
- cout<<"變數x的位址: "<<&x<<endl;
- cout<<"變數y的位址: "<<&y<<endl<<endl;
- sswap(&x,&y);
- cout<<"[對調後]"<<endl;
- cout<<"x="<<x<<endl;
- cout<<"y="<<y<<endl;
- cout<<"變數x的位址: "<<&x<<endl;
- cout<<"變數y的位址: "<<&y<<endl<<endl;
- }
- void sswap(int *a, int *b)
- {
- swap(*a, *b);
- }
複製代碼 |